You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ds...@apache.org on 2014/08/08 00:25:57 UTC

svn commit: r1616610 - in /lucene/dev/branches/branch_4x: ./ solr/ solr/core/ solr/core/src/java/org/apache/solr/search/ solr/core/src/test/org/apache/solr/search/

Author: dsmiley
Date: Thu Aug  7 22:25:57 2014
New Revision: 1616610

URL: http://svn.apache.org/r1616610
Log:
SOLR-6318: New terms QParser defaults to comma delimited now

Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/solr/   (props changed)
    lucene/dev/branches/branch_4x/solr/core/   (props changed)
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/TermsQParserPlugin.java
    lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java
    lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestQueryTypes.java

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/TermsQParserPlugin.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/TermsQParserPlugin.java?rev=1616610&r1=1616609&r2=1616610&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/TermsQParserPlugin.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/TermsQParserPlugin.java Thu Aug  7 22:25:57 2014
@@ -44,8 +44,8 @@ import java.util.regex.Pattern;
  * {@link TermQParserPlugin} but multi-valued, and supports a variety of internal algorithms.
  * <br>Parameters:
  * <br><code>f</code>: The field name (mandatory)
- * <br><code>separator</code>: the separator delimiting the values in the query string. By
- * default it's a " " which is special in that it splits on any consecutive whitespace.
+ * <br><code>separator</code>: the separator delimiting the values in the query string, defaulting to a comma.
+ * If it's a " " then it splits on any consecutive whitespace.
  * <br><code>method</code>: Any of termsFilter (default), booleanQuery, automaton, docValuesTermsFilter.
  * <p>
  * Note that if no values are specified then the query matches no documents.
@@ -106,7 +106,7 @@ public class TermsQParserPlugin extends 
       public Query parse() throws SyntaxError {
         String fname = localParams.get(QueryParsing.F);
         FieldType ft = req.getSchema().getFieldTypeNoEx(fname);
-        String separator = localParams.get(SEPARATOR, " ");
+        String separator = localParams.get(SEPARATOR, ",");
         String qstr = localParams.get(QueryParsing.V);//never null
         Method method = Method.valueOf(localParams.get(METHOD, Method.termsFilter.name()));
         //TODO pick the default method based on various heuristics from benchmarks

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java?rev=1616610&r1=1616609&r2=1616610&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java Thu Aug  7 22:25:57 2014
@@ -16,10 +16,6 @@ package org.apache.solr.search;
  * limitations under the License.
  */
 
-import java.util.HashSet;
-import java.util.Set;
-import java.util.Map;
-
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.QueryUtils;
 import org.apache.solr.SolrTestCaseJ4;
@@ -29,6 +25,10 @@ import org.apache.solr.response.SolrQuer
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
 
 
 /**
@@ -365,6 +365,10 @@ public class QueryEqualityTest extends S
     }
   }
 
+  public void testTerms() throws Exception {
+    assertQueryEquals("terms", "{!terms f=foo_i}10,20,30,-10,-20,-30", "{!terms f=foo_i}10,20,30,-10,-20,-30");
+  }
+
   public void testBlockJoin() throws Exception {
     assertQueryEquals("parent", "{!parent which=foo_s:parent}dude",
         "{!parent which=foo_s:parent}dude");

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestQueryTypes.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestQueryTypes.java?rev=1616610&r1=1616609&r2=1616610&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestQueryTypes.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestQueryTypes.java Thu Aug  7 22:25:57 2014
@@ -89,9 +89,9 @@ public class TestQueryTypes extends Abst
               );
 
       // terms qparser
-      //wrap in spaces if space separated
-      final String separator = f == "v_s" ? "separator='|'" : "";//defaults to space separated
-      String vMod = separator == "" && random().nextBoolean() ? " " + v + " " : v;
+      //wrap in spaces sometimes if space separated
+      final String separator = f == "v_s" ? "" : "separator=' '";//use space separated when field isn't v_s
+      String vMod = separator != "" && random().nextBoolean() ? " " + v + " " : v;
       assertQ(req( "q", "{!terms " + separator + " f=" +f+"}"+vMod)
               ,"//result[@numFound='1']"
               );
@@ -108,7 +108,7 @@ public class TestQueryTypes extends Abst
     );
 
     String termsMethod = new String[]{"termsFilter", "booleanQuery", "automaton", "docValuesTermsFilter"}[random().nextInt(4)];
-    assertQ(req( "q", "{!terms f=v_s method=" + termsMethod + " separator=|}other stuff|wow dude")
+    assertQ(req( "q", "{!terms f=v_s method=" + termsMethod + " }other stuff,wow dude")
         ,"//result[@numFound='2']"
     );