diff --git a/solr/core/src/java/org/apache/solr/search/TermsQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/TermsQParserPlugin.java
index 4d29f7d254f..3c8cb75b747 100644
--- a/solr/core/src/java/org/apache/solr/search/TermsQParserPlugin.java
+++ b/solr/core/src/java/org/apache/solr/search/TermsQParserPlugin.java
@@ -44,8 +44,8 @@ import java.util.regex.Pattern;
* {@link TermQParserPlugin} but multi-valued, and supports a variety of internal algorithms.
*
Parameters:
* f
: The field name (mandatory)
- * separator
: 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.
+ * separator
: the separator delimiting the values in the query string, defaulting to a comma.
+ * If it's a " " then it splits on any consecutive whitespace.
* method
: Any of termsFilter (default), booleanQuery, automaton, docValuesTermsFilter.
*
* Note that if no values are specified then the query matches no documents. @@ -106,7 +106,7 @@ public class TermsQParserPlugin extends QParserPlugin { 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 diff --git a/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java b/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java index 1320d614b9e..ab0cf15c6ee 100644 --- a/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java +++ b/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java @@ -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.SolrQueryResponse; 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 SolrTestCaseJ4 { } } + 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"); diff --git a/solr/core/src/test/org/apache/solr/search/TestQueryTypes.java b/solr/core/src/test/org/apache/solr/search/TestQueryTypes.java index 30a5a3c21a6..3f57ee5da0c 100644 --- a/solr/core/src/test/org/apache/solr/search/TestQueryTypes.java +++ b/solr/core/src/test/org/apache/solr/search/TestQueryTypes.java @@ -89,9 +89,9 @@ public class TestQueryTypes extends AbstractSolrTestCase { ); // 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 AbstractSolrTestCase { ); 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']" );