Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

Changed the query processed by the highlighter for DisMax: instead of using the whole query (which included boost and filter terms), the highlighting will be limited to the user's query terms by default.

Mike Klaas4202fc353ff7
diff --git a/CHANGES.txt b/CHANGES.txt
index 330e8fe6f14..43d4fdc8b99 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -38,7 +38,8 @@ New Features
1.
Changes in runtime behavior
- 1.
+ 1. Highlighting using DisMax will only pick up terms from the main
+ user query, not boost or filter queries (klaas).
Optimizations
1.
diff --git a/src/java/org/apache/solr/request/DisMaxRequestHandler.java b/src/java/org/apache/solr/request/DisMaxRequestHandler.java
index 597d2ec1a65..60b8ed1c087 100644
--- a/src/java/org/apache/solr/request/DisMaxRequestHandler.java
+++ b/src/java/org/apache/solr/request/DisMaxRequestHandler.java
@@ -268,19 +268,16 @@ public class DisMaxRequestHandler
BooleanQuery query = new BooleanQuery(true);
String minShouldMatch = params.get(DMP.MM, "100%");
-
Query dis = up.parse(userQuery);
+ Query parsedUserQuery = dis;
if (dis instanceof BooleanQuery) {
BooleanQuery t = new BooleanQuery();
U.flattenBooleanQuery(t, (BooleanQuery)dis);
-
- U.setMinShouldMatch(t, minShouldMatch);
-
- query.add(t, Occur.MUST);
- } else {
- query.add(dis, Occur.MUST);
- }
+ U.setMinShouldMatch(t, minShouldMatch);
+ parsedUserQuery = t;
+ }
+ query.add(parsedUserQuery, Occur.MUST);
/* * * Add on Phrases for the Query * * */
@@ -381,12 +378,9 @@ public class DisMaxRequestHandler
/* * * Highlighting/Summarizing * * */
if(HighlightingUtils.isHighlightingEnabled(req)) {
-
- BooleanQuery highlightQuery = new BooleanQuery();
- U.flattenBooleanQuery(highlightQuery, query);
String[] highFields = queryFields.keySet().toArray(new String[0]);
NamedList sumData =
- HighlightingUtils.doHighlighting(results.docList, highlightQuery,
+ HighlightingUtils.doHighlighting(results.docList, parsedUserQuery,
req, highFields);
if(sumData != null)
rsp.add("highlighting", sumData);