lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dsmi...@apache.org
Subject svn commit: r1616559 - 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/
Date Thu, 07 Aug 2014 18:04:52 GMT
Author: dsmiley
Date: Thu Aug  7 18:04:52 2014
New Revision: 1616559

URL: http://svn.apache.org/r1616559
Log:
SOLR-6318: New terms QParser

Added:
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/TermsQParserPlugin.java
      - copied, changed from r1616558, lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/TermsQParserPlugin.java
Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/solr/   (props changed)
    lucene/dev/branches/branch_4x/solr/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/branch_4x/solr/core/   (props changed)
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/QParserPlugin.java
    lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestQueryTypes.java

Modified: lucene/dev/branches/branch_4x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/CHANGES.txt?rev=1616559&r1=1616558&r2=1616559&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/solr/CHANGES.txt Thu Aug  7 18:04:52 2014
@@ -103,6 +103,9 @@ New Features
 * SOLR-6302: UpdateRequestHandlers are registered implicitly /update ,
   /update/json, /update/csv , /update/json/docs (Noble Paul)
 
+* SOLR-6318: New "terms" QParser for efficiently filtering documents by a list of values.
For
+  many values, it's more appropriate than a boolean query. (David Smiley)
+
 
 Bug Fixes
 ----------------------

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/QParserPlugin.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/QParserPlugin.java?rev=1616559&r1=1616558&r2=1616559&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/QParserPlugin.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/QParserPlugin.java
Thu Aug  7 18:04:52 2014
@@ -48,6 +48,7 @@ public abstract class QParserPlugin impl
     FieldQParserPlugin.NAME, FieldQParserPlugin.class,
     RawQParserPlugin.NAME, RawQParserPlugin.class,
     TermQParserPlugin.NAME, TermQParserPlugin.class,
+    TermsQParserPlugin.NAME, TermsQParserPlugin.class,
     NestedQParserPlugin.NAME, NestedQParserPlugin.class,
     FunctionRangeQParserPlugin.NAME, FunctionRangeQParserPlugin.class,
     SpatialFilterQParserPlugin.NAME, SpatialFilterQParserPlugin.class,

Copied: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/TermsQParserPlugin.java
(from r1616558, lucene/dev/trunk/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?p2=lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/TermsQParserPlugin.java&p1=lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/TermsQParserPlugin.java&r1=1616558&r2=1616559&rev=1616559&view=diff
==============================================================================
--- lucene/dev/trunk/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 18:04:52 2014
@@ -22,7 +22,7 @@ import org.apache.lucene.queries.TermsFi
 import org.apache.lucene.search.AutomatonQuery;
 import org.apache.lucene.search.BooleanClause;
 import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.DocValuesTermsFilter;
+import org.apache.lucene.search.FieldCacheTermsFilter;
 import org.apache.lucene.search.Filter;
 import org.apache.lucene.search.MultiTermQueryWrapperFilter;
 import org.apache.lucene.search.Query;
@@ -92,7 +92,7 @@ public class TermsQParserPlugin extends 
       //note: limited to one val per doc
       @Override
       Filter makeFilter(String fname, BytesRef[] byteRefs) {
-        return new DocValuesTermsFilter(fname, byteRefs);
+        return new FieldCacheTermsFilter(fname, byteRefs);
       }
     };
 

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=1616559&r1=1616558&r2=1616559&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 18:04:52 2014
@@ -30,21 +30,6 @@ public class TestQueryTypes extends Abst
   
   public String getCoreName() { return "basic"; }
 
-
-  @Override
-  public void setUp() throws Exception {
-    // if you override setUp or tearDown, you better call
-    // the super classes version
-    super.setUp();
-  }
-  @Override
-  public void tearDown() throws Exception {
-    // if you override setUp or tearDown, you better call
-    // the super classes version
-    super.tearDown();
-  }
-
-
   public void testQueryTypes() {
     assertU(adoc("id","0"));
     assertU(adoc("id","1", "v_t","Hello Dude"));
@@ -98,12 +83,36 @@ public class TestQueryTypes extends Abst
               ,"//result[@numFound='1']"
               );
 
+      // term qparser
+      assertQ(req( "q", "{!term f="+f+"}"+v)
+              ,"//result[@numFound='1']"
+              );
+
+      // 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;
+      assertQ(req( "q", "{!terms " + separator + " f=" +f+"}"+vMod)
+              ,"//result[@numFound='1']"
+              );
+
       // lucene range
       assertQ(req( "q", f + ":[\"" + v + "\" TO \"" + v + "\"]" )
               ,"//result[@numFound='1']"
               );
     }
 
+    // terms qparser, no values matches nothing
+    assertQ(req( "q", "*:*", "fq", "{!terms f=v_s}")
+        ,"//result[@numFound='0']"
+    );
+
+    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")
+        ,"//result[@numFound='2']"
+    );
+
+
     // frange and function query only work on single valued field types
     Object[] fc_vals = new Object[] {
       "id",999.0



Mime
View raw message