This is an automated email from the ASF dual-hosted git repository.
dsmiley pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/main by this push:
new 8d41ff5 SOLR-15962: surround parser & highlighting: ensure works
8d41ff5 is described below
commit 8d41ff575d893cc593366dea1873fe06bea8b2ea
Author: David Smiley <[email protected]>
AuthorDate: Sun Jan 30 00:43:33 2022 -0500
SOLR-15962: surround parser & highlighting: ensure works
---
.../org/apache/solr/search/SurroundQParserPlugin.java | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git
a/solr/core/src/java/org/apache/solr/search/SurroundQParserPlugin.java
b/solr/core/src/java/org/apache/solr/search/SurroundQParserPlugin.java
index e751988..c659a70 100644
--- a/solr/core/src/java/org/apache/solr/search/SurroundQParserPlugin.java
+++ b/solr/core/src/java/org/apache/solr/search/SurroundQParserPlugin.java
@@ -16,6 +16,7 @@
*/
package org.apache.solr.search;
+import java.io.IOException;
import org.apache.lucene.search.Query;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.SolrParams;
@@ -99,5 +100,19 @@ public class SurroundQParserPlugin extends QParserPlugin {
Query lquery = sq.makeLuceneQueryField(defaultField, bqFactory);
return lquery;
}
+
+ @Override
+ public Query getHighlightQuery() throws SyntaxError {
+ // Some highlighters (certainly UnifiedHighlighter) doesn't support
highlighting these
+ // queries in some modes because this special query doesn't implement
visit() properly.
+ // By rewriting, we get a SpanQuery, which does. Sometimes this can be
expensive like for
+ // some MultiTermQueries (MTQ) (e.g. a wildcard) but we don't expect it
to be here.
+ try {
+ return getQuery().rewrite(req.getSearcher().getIndexReader());
+ } catch (IOException e) {
+ log.warn("Couldn't get rewritten query for highlighting", e);
+ return getQuery();
+ }
+ }
}
}