You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by ho...@apache.org on 2010/02/13 06:02:57 UTC

svn commit: r909746 - in /lucene/solr/trunk: CHANGES.txt src/java/org/apache/solr/search/function/StringIndexDocValues.java

Author: hossman
Date: Sat Feb 13 05:02:56 2010
New Revision: 909746

URL: http://svn.apache.org/viewvc?rev=909746&view=rev
Log:
SOLR-1771: Improved error message when StringIndex cannot be initialized for a function query

Modified:
    lucene/solr/trunk/CHANGES.txt
    lucene/solr/trunk/src/java/org/apache/solr/search/function/StringIndexDocValues.java

Modified: lucene/solr/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/CHANGES.txt?rev=909746&r1=909745&r2=909746&view=diff
==============================================================================
--- lucene/solr/trunk/CHANGES.txt (original)
+++ lucene/solr/trunk/CHANGES.txt Sat Feb 13 05:02:56 2010
@@ -233,7 +233,10 @@
 * Upgraded to Lucene 2.9-dev r900226 (koji)
 
 * SOLR-1727: SolrEventListener should extend NamedListInitializedPlugin (noble)
-  
+
+* SOLR-1771: Improved error message when StringIndex cannot be initialized
+  for a function query (hossman)
+
 Build
 ----------------------
 

Modified: lucene/solr/trunk/src/java/org/apache/solr/search/function/StringIndexDocValues.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/search/function/StringIndexDocValues.java?rev=909746&r1=909745&r2=909746&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/search/function/StringIndexDocValues.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/search/function/StringIndexDocValues.java Sat Feb 13 05:02:56 2010
@@ -32,12 +32,16 @@
     protected final ValueSource vs;
 
     public StringIndexDocValues(ValueSource vs, IndexReader reader, String field) throws IOException {
-      index = FieldCache.DEFAULT.getStringIndex(reader, field);
+      try {
+        index = FieldCache.DEFAULT.getStringIndex(reader, field);
+      } catch (RuntimeException e) {
+        throw new StringIndexException(field, e);
+      }
       order = index.order;
       lookup = index.lookup;
       this.vs = vs;
     }
-
+  
     protected abstract String toTerm(String readableValue);
 
    @Override
@@ -82,4 +86,12 @@
       return vs.description() + '=' + strVal(doc);
     }
 
+  public static final class StringIndexException extends RuntimeException {
+    public StringIndexException(final String fieldName,
+                                final RuntimeException cause) {
+      super("Can't initialize StringIndex to generate (function) " +
+            "DocValues for field: " + fieldName, cause);
+    }
   }
+  
+}