mirror of https://github.com/apache/lucene.git
SOLR-3278: Negative boost support to the Extended Dismax Query Parser Boost Query
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1305908 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ce1cead6eb
commit
aed1330b54
|
@ -250,6 +250,9 @@ New Features
|
||||||
the same behaviour as solr 3.5, favouring throughput over latency. More
|
the same behaviour as solr 3.5, favouring throughput over latency. More
|
||||||
information can be found on the wiki (http://wiki.apache.org/solr/SolrConfigXml) (Greg Bowyer)
|
information can be found on the wiki (http://wiki.apache.org/solr/SolrConfigXml) (Greg Bowyer)
|
||||||
|
|
||||||
|
* SOLR-3278: Negative boost support to the Extended Dismax Query Parser Boost Query (bq).
|
||||||
|
(James Dyer)
|
||||||
|
|
||||||
Optimizations
|
Optimizations
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
|
@ -344,13 +344,17 @@ class ExtendedDismaxQParser extends QParser {
|
||||||
|
|
||||||
/* * * Boosting Query * * */
|
/* * * Boosting Query * * */
|
||||||
boostParams = solrParams.getParams(DisMaxParams.BQ);
|
boostParams = solrParams.getParams(DisMaxParams.BQ);
|
||||||
//List<Query> boostQueries = U.parseQueryStrings(req, boostParams);
|
|
||||||
boostQueries=null;
|
boostQueries=null;
|
||||||
if (boostParams!=null && boostParams.length>0) {
|
if (boostParams!=null && boostParams.length>0) {
|
||||||
|
Map<String,Float> bqBoosts = SolrPluginUtils.parseFieldBoosts(boostParams);
|
||||||
boostQueries = new ArrayList<Query>();
|
boostQueries = new ArrayList<Query>();
|
||||||
for (String qs : boostParams) {
|
for (Map.Entry<String,Float> bqs : bqBoosts.entrySet()) {
|
||||||
if (qs.trim().length()==0) continue;
|
if (bqs.getKey().trim().length()==0) continue;
|
||||||
Query q = subQuery(qs, null).getQuery();
|
Query q = subQuery(bqs.getKey(), null).getQuery();
|
||||||
|
Float b = bqs.getValue();
|
||||||
|
if(b!=null) {
|
||||||
|
q.setBoost(b);
|
||||||
|
}
|
||||||
boostQueries.add(q);
|
boostQueries.add(q);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,9 @@ public class TestExtendedDismaxParser extends AbstractSolrTestCase {
|
||||||
assertU(adoc("id", "49", "text_sw", "start the big apple end", "foo_i","-100"));
|
assertU(adoc("id", "49", "text_sw", "start the big apple end", "foo_i","-100"));
|
||||||
assertU(adoc("id", "50", "text_sw", "start new big city end"));
|
assertU(adoc("id", "50", "text_sw", "start new big city end"));
|
||||||
assertU(adoc("id", "51", "store", "12.34,-56.78"));
|
assertU(adoc("id", "51", "store", "12.34,-56.78"));
|
||||||
|
assertU(adoc("id", "52", "text_sw", "tekna theou klethomen"));
|
||||||
|
assertU(adoc("id", "53", "text_sw", "nun tekna theou esmen"));
|
||||||
|
assertU(adoc("id", "54", "text_sw", "phanera estin ta tekna tou theou"));
|
||||||
assertU(commit());
|
assertU(commit());
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
@ -295,6 +298,22 @@ public class TestExtendedDismaxParser extends AbstractSolrTestCase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testBoostQuery() {
|
||||||
|
assertQ(
|
||||||
|
req("q", "tekna", "qf", "text_sw", "defType", "edismax", "bq", "id:54^100", "bq", "id: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']"
|
||||||
|
);
|
||||||
|
|
||||||
|
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"),
|
||||||
|
"//doc[1]/str[@name='id'][.='53']",
|
||||||
|
"//doc[2]/str[@name='id'][.='52']",
|
||||||
|
"//doc[3]/str[@name='id'][.='54']"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public void testUserFields() {
|
public void testUserFields() {
|
||||||
String oner = "*[count(//doc)=1]";
|
String oner = "*[count(//doc)=1]";
|
||||||
String nor = "*[count(//doc)=0]";
|
String nor = "*[count(//doc)=0]";
|
||||||
|
|
Loading…
Reference in New Issue