SOLR-1268: ignore undefined field

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@897611 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Koji Sekiguchi 2010-01-10 10:29:08 +00:00
parent f6d7daf239
commit 2df8e5d5f5
1 changed files with 9 additions and 3 deletions

View File

@ -346,9 +346,14 @@ public class DefaultSolrHighlighter extends SolrHighlighter implements PluginInf
return fragments;
}
/*
* If fieldName is undefined, this method returns false, then
* doHighlightingByHighlighter() will do nothing for the field.
*/
private boolean useFastVectorHighlighter( SolrParams params, IndexSchema schema, String fieldName ){
SchemaField schemaField = schema.getField( fieldName );
return schemaField.storeTermPositions() &&
SchemaField schemaField = schema.getFieldOrNull( fieldName );
return schemaField != null &&
schemaField.storeTermPositions() &&
schemaField.storeTermOffsets() &&
!params.getFieldBool( fieldName, HighlightParams.USE_HIGHLIGHTER, false );
}
@ -357,7 +362,8 @@ public class DefaultSolrHighlighter extends SolrHighlighter implements PluginInf
int docId, Document doc, String fieldName ) throws IOException {
SolrParams params = req.getParams();
String[] docTexts = doc.getValues(fieldName);
if (docTexts == null) return;
// according to Document javadoc, doc.getValues() never returns null. check empty instead of null
if (docTexts.length == 0) return;
SolrIndexSearcher searcher = req.getSearcher();
IndexSchema schema = searcher.getSchema();