LUCENE-1889: pass the reader to FVH so it can rewrite multitermqueries

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1167008 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2011-09-09 05:46:21 +00:00
parent 9e15eeaa86
commit 20c03511c8
3 changed files with 4 additions and 2 deletions

View File

@ -77,6 +77,8 @@ public class FastVectorHighlighter {
* @return the created {@link FieldQuery} object
*/
public FieldQuery getFieldQuery( Query query ) {
// TODO: should we deprecate this?
// because if there is no reader, then we cannot rewrite MTQ.
try {
return new FieldQuery( query, null, phraseHighlight, fieldMatch );
} catch (IOException e) {

View File

@ -102,7 +102,7 @@ public class FieldQuery {
if( !flatQueries.contains( sourceQuery ) )
flatQueries.add( sourceQuery );
}
else if (sourceQuery instanceof MultiTermQuery) {
else if (sourceQuery instanceof MultiTermQuery && reader != null) {
MultiTermQuery copy = (MultiTermQuery) sourceQuery.clone();
copy.setRewriteMethod(new MultiTermQuery.TopTermsScoringBooleanQueryRewrite(MAX_MTQ_TERMS));
BooleanQuery mtqTerms = (BooleanQuery) copy.rewrite(reader);

View File

@ -364,7 +364,7 @@ public class DefaultSolrHighlighter extends SolrHighlighter implements PluginInf
// FVH cannot process hl.requireFieldMatch parameter per-field basis
params.getBool( HighlightParams.FIELD_MATCH, false ) );
fvh.setPhraseLimit(params.getInt(HighlightParams.PHRASE_LIMIT, Integer.MAX_VALUE));
FieldQuery fieldQuery = fvh.getFieldQuery( query );
FieldQuery fieldQuery = fvh.getFieldQuery( query, searcher.getIndexReader() );
// Highlight each document
DocIterator iterator = docs.iterator();