Skip to content

Apache Lucene open-source search software

SOLR-3823: Fix 'bq' parsing in edismax. Please note that this required reverting the negative boost support added by SOLR-3278

Chris M. Hostetter64d204c04e77
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 2d68d768955..f86b900a613 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -149,6 +149,8 @@ Bug Fixes
if it is configured as multiValued - this has never been properly supported,
but previously failed silently in odd ways. (hossman)
+* SOLR-3823: Fix 'bq' parsing in edismax. Please note that this required
+ reverting the negative boost support added by SOLR-3278 (hossman)
Other Changes
----------------------
diff --git a/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java
index 7c5c381e9cc..c2ecc85eb94 100755
--- a/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java
+++ b/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java
@@ -346,17 +346,13 @@ class ExtendedDismaxQParser extends QParser {
/* * * Boosting Query * * */
boostParams = solrParams.getParams(DisMaxParams.BQ);
+ //List<Query> boostQueries = U.parseQueryStrings(req, boostParams);
boostQueries=null;
if (boostParams!=null && boostParams.length>0) {
- Map<String,Float> bqBoosts = SolrPluginUtils.parseFieldBoosts(boostParams);
boostQueries = new ArrayList<Query>();
- for (Map.Entry<String,Float> bqs : bqBoosts.entrySet()) {
- if (bqs.getKey().trim().length()==0) continue;
- Query q = subQuery(bqs.getKey(), null).getQuery();
- Float b = bqs.getValue();
- if(b!=null) {
- q.setBoost(b);
- }
+ for (String qs : boostParams) {
+ if (qs.trim().length()==0) continue;
+ Query q = subQuery(qs, null).getQuery();
boostQueries.add(q);
}
}
diff --git a/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java b/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java
index 8ce0d575d0c..92302947053 100755
--- a/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java
+++ b/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java
@@ -343,8 +343,24 @@ public class TestExtendedDismaxParser extends AbstractSolrTestCase {
"//doc[3]/str[@name='id'][.='52']"
);
+ // non-trivial bqs
+ assertQ(req("q", "tekna",
+ "qf", "text_sw",
+ "defType", "edismax",
+ "bq", "(text_sw:blasdfadsf id:54)^100",
+ "bq", "id:[53 TO 53]^10",
+ "fq", "id:[52 TO 54]",
+ "fl", "id,score"),
+ "//doc[1]/str[@name='id'][.='54']",
+ "//doc[2]/str[@name='id'][.='53']",
+ "//doc[3]/str[@name='id'][.='52']"
+ );
+
+ // genuine negative boosts are not legal
+ // see SOLR-3823, SOLR-3278, LUCENE-4378 and
+ // https://wiki.apache.org/solr/SolrRelevancyFAQ#How_do_I_give_a_negative_.28or_very_low.29_boost_to_documents_that_match_a_query.3F
assertQ(
- req("q", "tekna", "qf", "text_sw", "defType", "edismax", "bq", "id:54^-100", "bq", "id:53^10", "bq", "id:52", "fq", "id:[52 TO 54]", "fl", "id,score"),
+ req("q", "tekna", "qf", "text_sw", "defType", "edismax", "bq", "(*:* -id:54)^100", "bq", "id:53^10", "bq", "id:52", "fq", "id:[52 TO 54]", "fl", "id,score"),
"//doc[1]/str[@name='id'][.='53']",
"//doc[2]/str[@name='id'][.='52']",
"//doc[3]/str[@name='id'][.='54']"