From dc1db925651f662740cfc0d8990a5bda2f403e87 Mon Sep 17 00:00:00 2001 From: ljak Date: Wed, 13 Dec 2023 10:53:54 -0500 Subject: [PATCH 1/2] Made the UnifiedHighlighter's hasUnrecognizedQuery function processes FunctionQuery the same way as MatchAllDocsQuery and MatchNoDocsQuery queries for performance reasons. --- .../apache/lucene/search/uhighlight/UnifiedHighlighter.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/UnifiedHighlighter.java b/lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/UnifiedHighlighter.java index 4f2d4af6da0..a940dcec60d 100644 --- a/lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/UnifiedHighlighter.java +++ b/lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/UnifiedHighlighter.java @@ -49,6 +49,7 @@ import org.apache.lucene.index.StoredFieldVisitor; import org.apache.lucene.index.StoredFields; import org.apache.lucene.index.Term; import org.apache.lucene.index.TermVectors; +import org.apache.lucene.queries.function.FunctionQuery; import org.apache.lucene.queries.spans.SpanQuery; import org.apache.lucene.search.DocIdSetIterator; import org.apache.lucene.search.IndexSearcher; @@ -1130,7 +1131,7 @@ public class UnifiedHighlighter { @Override public void visitLeaf(Query query) { if (MultiTermHighlighting.canExtractAutomataFromLeafQuery(query) == false) { - if (!(query instanceof MatchAllDocsQuery || query instanceof MatchNoDocsQuery)) { + if (!(query instanceof MatchAllDocsQuery || query instanceof MatchNoDocsQuery || query instanceof FunctionQuery)) { hasUnknownLeaf[0] = true; } } From 270dcf89738763c7e929255f95c8701d91e2e2d9 Mon Sep 17 00:00:00 2001 From: Laurent Date: Wed, 13 Dec 2023 12:40:01 -0500 Subject: [PATCH 2/2] tidy-ed --- .../apache/lucene/search/uhighlight/UnifiedHighlighter.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/UnifiedHighlighter.java b/lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/UnifiedHighlighter.java index a940dcec60d..532b1a0e5e6 100644 --- a/lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/UnifiedHighlighter.java +++ b/lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/UnifiedHighlighter.java @@ -1131,7 +1131,9 @@ public class UnifiedHighlighter { @Override public void visitLeaf(Query query) { if (MultiTermHighlighting.canExtractAutomataFromLeafQuery(query) == false) { - if (!(query instanceof MatchAllDocsQuery || query instanceof MatchNoDocsQuery || query instanceof FunctionQuery)) { + if (!(query instanceof MatchAllDocsQuery + || query instanceof MatchNoDocsQuery + || query instanceof FunctionQuery)) { hasUnknownLeaf[0] = true; } }