Apache Lucene open-source search software
SOLR-1771: Improved error message when StringIndex cannot be initialized for a function query
Chris M. Hostetter87b0e274e12c
diff --git a/CHANGES.txt b/CHANGES.txtindex aca66449612..7ed46c78885 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -233,7 +233,10 @@ Other Changes* 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----------------------diff --git a/src/java/org/apache/solr/search/function/StringIndexDocValues.java b/src/java/org/apache/solr/search/function/StringIndexDocValues.javaindex 79a7f8ea308..980affe8cde 100755--- a/src/java/org/apache/solr/search/function/StringIndexDocValues.java+++ b/src/java/org/apache/solr/search/function/StringIndexDocValues.java@@ -32,12 +32,16 @@ public abstract class StringIndexDocValues extends DocValues {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 @@ public abstract class StringIndexDocValues extends DocValues {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);+ }}++}