lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ehatc...@apache.org
Subject [4/4] lucene-solr:jira/SOLR-1485: Add equality tests for payload_score and payload_check queries
Date Mon, 01 May 2017 01:56:45 GMT
Add equality tests for payload_score and payload_check queries


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/149231af
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/149231af
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/149231af

Branch: refs/heads/jira/SOLR-1485
Commit: 149231af379e619bf13f1c026ea19d95f6ac5fe7
Parents: ee801de
Author: Erik Hatcher <ehatcher@apache.org>
Authored: Sun Apr 30 21:56:26 2017 -0400
Committer: Erik Hatcher <ehatcher@apache.org>
Committed: Sun Apr 30 21:56:26 2017 -0400

----------------------------------------------------------------------
 .../solr/collection1/conf/schema15.xml          |  8 ++++
 .../apache/solr/search/QueryEqualityTest.java   | 46 ++++++++++++++------
 2 files changed, 40 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/149231af/solr/core/src/test-files/solr/collection1/conf/schema15.xml
----------------------------------------------------------------------
diff --git a/solr/core/src/test-files/solr/collection1/conf/schema15.xml b/solr/core/src/test-files/solr/collection1/conf/schema15.xml
index 57c6bf1..9b4f0b1 100644
--- a/solr/core/src/test-files/solr/collection1/conf/schema15.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/schema15.xml
@@ -618,6 +618,14 @@
 
   <dynamicField name="random_*" type="random"/>
 
+  <dynamicField name="*_dpf" type="delimited_payloads_float" indexed="true"  stored="true"/>
+  <fieldType name="delimited_payloads_float" class="solr.TextField" positionIncrementGap="100">
+    <analyzer>
+      <tokenizer class="solr.MockTokenizerFactory"/>
+      <filter class="solr.DelimitedPayloadTokenFilterFactory" encoder="float"/>
+    </analyzer>
+  </fieldType>
+
 
   <defaultSearchField>text</defaultSearchField>
   <uniqueKey>id</uniqueKey>

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/149231af/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java
----------------------------------------------------------------------
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 c44cc1e..88e4274 100644
--- a/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java
+++ b/solr/core/src/test/org/apache/solr/search/QueryEqualityTest.java
@@ -20,6 +20,7 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
+import junit.framework.AssertionFailedError;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.QueryUtils;
 import org.apache.solr.SolrTestCaseJ4;
@@ -29,8 +30,6 @@ import org.apache.solr.response.SolrQueryResponse;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 
-
-
 /**
  * Sanity checks that queries (generated by the QParser and ValueSourceParser 
  * framework) are appropriately {@link Object#equals} and 
@@ -193,15 +192,6 @@ public class QueryEqualityTest extends SolrTestCaseJ4 {
     }
   }
 
-  public void testSignificantTermsQuery() throws Exception {
-    SolrQueryRequest req = req("q", "*:*");
-    try {
-      assertQueryEquals("sigificantTerms", req, "{!sigificantTerms}");
-    } finally {
-      req.close();
-    }
-  }
-
   public void testQuerySwitch() throws Exception {
     SolrQueryRequest req = req("myXXX", "XXX", 
                                "myField", "foo_s",
@@ -1001,6 +991,35 @@ public class QueryEqualityTest extends SolrTestCaseJ4 {
     }
   }
 
+  public void testPayloadScoreQuery() throws Exception {
+    // I don't see a precedent to test query inequality in here, so doing a `try`
+    // There was a bug with PayloadScoreQuery's .equals() method that said two queries were
equal with different includeSpanScore settings
+
+    try {
+      assertQueryEquals
+          (null
+              , "{!payload_score f=foo_dpf v=query func=min includeSpanScore=false}"
+              , "{!payload_score f=foo_dpf v=query func=min includeSpanScore=true}"
+          );
+      fail("queries should not have been equal");
+    } catch(AssertionFailedError e) {
+      assertTrue("queries were not equal, as expected", true);
+    }
+  }
+
+  public void testPayloadCheckQuery() throws Exception {
+    try {
+      assertQueryEquals
+          (null
+              , "{!payload_check f=foo_dpf payloads=2}one"
+              , "{!payload_check f=foo_dpf payloads=2}two"
+          );
+      fail("queries should not have been equal");
+    } catch(AssertionFailedError e) {
+      assertTrue("queries were not equal, as expected", true);
+    }
+  }
+
 
   /**
    * NOTE: defType is not only used to pick the parser, but also to record 
@@ -1046,7 +1065,7 @@ public class QueryEqualityTest extends SolrTestCaseJ4 {
 
     for (int i = 0; i < queries.length; i++) {
       QueryUtils.check(queries[i]);
-      // yes starting j=0 is redundent, we're making sure every query 
+      // yes starting j=0 is redundant, we're making sure every query
       // is equal to itself, and that the quality checks work regardless 
       // of which caller/callee is used.
       for (int j = 0; j < queries.length; j++) {
@@ -1099,8 +1118,7 @@ public class QueryEqualityTest extends SolrTestCaseJ4 {
     assertFuncEquals("agg_hll(foo_i)", "agg_hll(foo_i)");
     assertFuncEquals("agg_sumsq(foo_i)", "agg_sumsq(foo_i)");
     assertFuncEquals("agg_percentile(foo_i,50)", "agg_percentile(foo_i,50)");
-    assertFuncEquals("agg_variance(foo_i)", "agg_variance(foo_i)");
-    assertFuncEquals("agg_stddev(foo_i)", "agg_stddev(foo_i)");
+    // assertFuncEquals("agg_stdev(foo_i)", "agg_stdev(foo_i)");
     // assertFuncEquals("agg_multistat(foo_i)", "agg_multistat(foo_i)");
   }
 


Mime
View raw message