From 759d7d693d07cb9661a7484a9b837d8aa23b11b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Laleve=CC=81e?= Date: Mon, 27 Jun 2011 11:42:27 +0200 Subject: [PATCH] Support for highlighting of phrase prefix queries --- .../lucene/search/vectorhighlight/CustomFieldQuery.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/elasticsearch/src/main/java/org/apache/lucene/search/vectorhighlight/CustomFieldQuery.java b/modules/elasticsearch/src/main/java/org/apache/lucene/search/vectorhighlight/CustomFieldQuery.java index 19662ebda6b..82cc7bb5bbc 100644 --- a/modules/elasticsearch/src/main/java/org/apache/lucene/search/vectorhighlight/CustomFieldQuery.java +++ b/modules/elasticsearch/src/main/java/org/apache/lucene/search/vectorhighlight/CustomFieldQuery.java @@ -23,6 +23,7 @@ import org.apache.lucene.index.IndexReader; 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 class CustomFieldQuery extends FieldQuery { } 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); }