Permalink
Browse files

Support for highlighting of phrase prefix queries

  • Loading branch information...
1 parent ce6fbc6 commit 759d7d693d07cb9661a7484a9b837d8aa23b11b5 @nlalevee nlalevee committed with kimchy Jun 27, 2011
@@ -23,6 +23,7 @@
import org.apache.lucene.index.Term;
import org.apache.lucene.search.*;
import org.apache.lucene.search.spans.SpanTermQuery;
+import org.elasticsearch.common.lucene.search.MultiPhrasePrefixQuery;
import org.elasticsearch.common.lucene.search.TermFilter;
import org.elasticsearch.common.lucene.search.XBooleanFilter;
import org.elasticsearch.common.lucene.search.function.FunctionScoreQuery;
@@ -103,6 +104,12 @@ public CustomFieldQuery(Query query, boolean phraseHighlight, boolean fieldMatch
} else if (sourceQuery instanceof FilteredQuery) {
flatten(((FilteredQuery) sourceQuery).getQuery(), flatQueries);
flatten(((FilteredQuery) sourceQuery).getFilter(), flatQueries);
+ } else if (sourceQuery instanceof MultiPhrasePrefixQuery) {
+ try {
+ flatten(sourceQuery.rewrite(reader.get()), flatQueries);
+ } catch (IOException e) {
+ // ignore
+ }
} else {
super.flatten(sourceQuery, flatQueries);
}

0 comments on commit 759d7d6

Please sign in to comment.