From 4202fc353ff70264420a20be7f0296a468b775ca Mon Sep 17 00:00:00 2001 From: Mike Klaas Date: Thu, 4 Jan 2007 22:47:54 +0000 Subject: [PATCH] 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. --This line, and those below, will be ignored-- M CHANGES.txt M src/java/org/apache/solr/request/DisMaxRequestHandler.java git-svn-id: https://svn.apache.org/repos/asf/incubator/solr/trunk@492793 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 3 ++- .../solr/request/DisMaxRequestHandler.java | 18 ++++++------------ 2 files changed, 8 insertions(+), 13 deletions(-) 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);