Support for highlighting of phrase prefix queries
This commit is contained in:
parent
ce6fbc687d
commit
759d7d693d
|
@ -23,6 +23,7 @@ import org.apache.lucene.index.IndexReader;
|
||||||
import org.apache.lucene.index.Term;
|
import org.apache.lucene.index.Term;
|
||||||
import org.apache.lucene.search.*;
|
import org.apache.lucene.search.*;
|
||||||
import org.apache.lucene.search.spans.SpanTermQuery;
|
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.TermFilter;
|
||||||
import org.elasticsearch.common.lucene.search.XBooleanFilter;
|
import org.elasticsearch.common.lucene.search.XBooleanFilter;
|
||||||
import org.elasticsearch.common.lucene.search.function.FunctionScoreQuery;
|
import org.elasticsearch.common.lucene.search.function.FunctionScoreQuery;
|
||||||
|
@ -103,6 +104,12 @@ public class CustomFieldQuery extends FieldQuery {
|
||||||
} else if (sourceQuery instanceof FilteredQuery) {
|
} else if (sourceQuery instanceof FilteredQuery) {
|
||||||
flatten(((FilteredQuery) sourceQuery).getQuery(), flatQueries);
|
flatten(((FilteredQuery) sourceQuery).getQuery(), flatQueries);
|
||||||
flatten(((FilteredQuery) sourceQuery).getFilter(), flatQueries);
|
flatten(((FilteredQuery) sourceQuery).getFilter(), flatQueries);
|
||||||
|
} else if (sourceQuery instanceof MultiPhrasePrefixQuery) {
|
||||||
|
try {
|
||||||
|
flatten(sourceQuery.rewrite(reader.get()), flatQueries);
|
||||||
|
} catch (IOException e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
super.flatten(sourceQuery, flatQueries);
|
super.flatten(sourceQuery, flatQueries);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue