You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ja...@apache.org on 2012/04/14 00:22:03 UTC

svn commit: r1325987 - in /lucene/dev/trunk/solr: CHANGES.txt core/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java

Author: janhoy
Date: Fri Apr 13 22:22:02 2012
New Revision: 1325987

URL: http://svn.apache.org/viewvc?rev=1325987&view=rev
Log:
SOLR-3352: eDismax: pf2 should kick in for a query with 2 terms

Modified:
    lucene/dev/trunk/solr/CHANGES.txt
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java

Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1325987&r1=1325986&r2=1325987&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Fri Apr 13 22:22:02 2012
@@ -370,6 +370,8 @@ Bug Fixes
   
 * SOLR-3214: If you use multiple fl entries rather than a comma separated list, all but the first
   entry 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
 ----------------------

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java?rev=1325987&r1=1325986&r2=1325987&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java Fri Apr 13 22:22:02 2012
@@ -457,7 +457,7 @@ class ExtendedDismaxQParser extends QPar
     throws ParseException {
     
     if (null == fields || fields.isEmpty() || 
-        null == clauses || clauses.size() <= shingleSize ) 
+        null == clauses || clauses.size() < shingleSize ) 
       return;
     
     if (0 == shingleSize) shingleSize = clauses.size();

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java?rev=1325987&r1=1325986&r2=1325987&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java Fri Apr 13 22:22:02 2012
@@ -530,4 +530,72 @@ public class TestExtendedDismaxParser ex
             "//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']"); 
+  }
 }