SOLR-1771: Improved error message when StringIndex cannot be initialized for a function query

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@909746 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris M. Hostetter 2010-02-13 05:02:56 +00:00
parent 5bfe85082e
commit 87b0e274e1
2 changed files with 18 additions and 3 deletions

View File

@ -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
----------------------

View File

@ -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);
}
}
}