Apache Lucene open-source search software
SOLR-3352: eDismax: pf2 should kick in for a query with 2 terms
Jan Høydahl2351e43debf3
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 2f9f5d34943..f2b24463780 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -370,6 +370,8 @@ Bug Fixes* SOLR-3214: If you use multiple fl entries rather than a comma separated list, all but the firstentry can be ignored if you are using distributed search. (Tomas Fernandez Lobbe via Mark Miller)++* SOLR-3352: eDismax: pf2 should kick in for a query with 2 terms (janhoy)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.javaindex 3f94783be1b..4360ec02a5f 100755--- a/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java+++ b/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java@@ -457,7 +457,7 @@ class ExtendedDismaxQParser extends QParser {throws ParseException {if (null == fields || fields.isEmpty() ||- null == clauses || clauses.size() <= shingleSize )+ null == clauses || clauses.size() < shingleSize )return;if (0 == shingleSize) shingleSize = clauses.size();diff --git a/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java b/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.javaindex 67193f835fd..d5c258a6ade 100755--- a/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java+++ b/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java@@ -530,4 +530,72 @@ public class TestExtendedDismaxParser extends AbstractSolrTestCase {"//str[@name='id'][.='145']","//str[@name='id'][.='146']");}++ // test phrase fields including pf2 pf3 and phrase slop+ public void testPfPs() {+ assertU(adoc("id", "s0", "phrase_sw", "foo bar a b c", "boost_d", "1.0"));+ assertU(adoc("id", "s1", "phrase_sw", "foo a bar b c", "boost_d", "2.0"));+ assertU(adoc("id", "s2", "phrase_sw", "foo a b bar c", "boost_d", "3.0"));+ assertU(adoc("id", "s3", "phrase_sw", "foo a b c bar", "boost_d", "4.0"));+ assertU(commit());++ assertQ("default order assumption wrong",+ req("q", "foo bar",+ "qf", "phrase_sw",+ "bf", "boost_d",+ "fl", "score,*",+ "defType", "edismax"),+ "//doc[1]/str[@name='id'][.='s3']",+ "//doc[2]/str[@name='id'][.='s2']",+ "//doc[3]/str[@name='id'][.='s1']",+ "//doc[4]/str[@name='id'][.='s0']");++ assertQ("pf not working",+ req("q", "foo bar",+ "qf", "phrase_sw",+ "pf", "phrase_sw^10",+ "bf", "boost_d",+ "fl", "score,*",+ "defType", "edismax"),+ "//doc[1]/str[@name='id'][.='s0']");++ assertQ("pf2 not working",+ req("q", "foo bar",+ "qf", "phrase_sw",+ "pf2", "phrase_sw^10",+ "bf", "boost_d",+ "fl", "score,*",+ "defType", "edismax"),+ "//doc[1]/str[@name='id'][.='s0']");++ assertQ("pf3 not working",+ req("q", "a b bar",+ "qf", "phrase_sw",+ "pf3", "phrase_sw^10",+ "bf", "boost_d",+ "fl", "score,*",+ "defType", "edismax"),+ "//doc[1]/str[@name='id'][.='s2']");++ assertQ("ps not working for pf2",+ req("q", "bar foo",+ "qf", "phrase_sw",+ "pf2", "phrase_sw^10",+ "ps", "2",+ "bf", "boost_d",+ "fl", "score,*",+ "defType", "edismax"),+ "//doc[1]/str[@name='id'][.='s0']");++ assertQ("ps not working for pf3",+ req("q", "a bar foo",+ "qf", "phrase_sw",+ "pf3", "phrase_sw^10",+ "ps", "3",+ "bf", "boost_d",+ "fl", "score,*",+ "debugQuery", "true",+ "defType", "edismax"),+ "//doc[1]/str[@name='id'][.='s1']");+ }}