You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ho...@apache.org on 2020/07/05 22:51:55 UTC

[lucene-solr] branch branch_8x updated: SOLR-14595: add AwaitsFix test to TestJsonFacetRefinement demonstrating problem, and work around to randomized testing in TestCloudJSONFacetSKGEquiv

This is an automated email from the ASF dual-hosted git repository.

hossman pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/branch_8x by this push:
     new 87436b0  SOLR-14595: add AwaitsFix test to TestJsonFacetRefinement demonstrating problem, and work around to randomized testing in TestCloudJSONFacetSKGEquiv
87436b0 is described below

commit 87436b0b9af2aedcf86904dbe78c0c4631d6c551
Author: Chris Hostetter <ho...@apache.org>
AuthorDate: Sun Jul 5 13:28:08 2020 -0700

    SOLR-14595: add AwaitsFix test to TestJsonFacetRefinement demonstrating problem, and work around to randomized testing in TestCloudJSONFacetSKGEquiv
    
    (cherry picked from commit fea6c1b9daa243e48297b4ba5a1ece68b8790a5b)
---
 .../search/facet/TestCloudJSONFacetSKGEquiv.java   | 20 ++++++++--
 .../solr/search/facet/TestJsonFacetRefinement.java | 43 ++++++++++++++++++++++
 2 files changed, 60 insertions(+), 3 deletions(-)

diff --git a/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKGEquiv.java b/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKGEquiv.java
index cab7df4..276dcb9 100644
--- a/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKGEquiv.java
+++ b/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKGEquiv.java
@@ -307,7 +307,7 @@ public class TestCloudJSONFacetSKGEquiv extends SolrCloudTestCase {
     } 
 
   }
-  
+
   /** 
    * Test some small, hand crafted, but non-trivial queries that are
    * easier to trace/debug then a pure random monstrosity.
@@ -717,7 +717,7 @@ public class TestCloudJSONFacetSKGEquiv extends SolrCloudTestCase {
       final String facetField = randomFacetField(random());
       return new TermFacet(facetField,
                            map("limit", randomLimitParam(random()),
-                               "overrequest", randomOverrequestParam(random()),
+                               "overrequest", randomOverrequestParam(random(), sort),
                                "prefix", randomPrefixParam(random(), facetField),
                                "perSeg", randomPerSegParam(random()),
                                "sort", sort,
@@ -896,11 +896,25 @@ public class TestCloudJSONFacetSKGEquiv extends SolrCloudTestCase {
     
     /**
      * picks a random value for the "overrequest" param, biased in favor of interesting test cases.
+     * <p>
+     * <b>NOTE:</b> due to variations in overrequest behavior betewen <code>metod:enum<code> and other 
+     * processors (see <a href="https://issues.apache.org/jira/browse/SOLR-14595">SOLR-14595</a>) this 
+     * method takes in the "sort" param and returns a constant value of <code>0</code> if the sort is 
+     * <code>index asc</code> to ensure that the set of candidate buckets considered during merging 
+     * (and refinement) is consistent regardless of what processor is used (and/or what sort is used 
+     * on the parent facet)
+     * </p>
      *
      * @return a number to specify in the request, or null to specify nothing (trigger default behavior)
      * @see #UNIQUE_FIELD_VALS
+     * @see <a href="https://issues.apache.org/jira/browse/SOLR-14595">SOLR-14595</a>
      */
-    public static Integer randomOverrequestParam(final Random r) {
+    public static Integer randomOverrequestParam(final Random r, final String sort) {
+
+      if ("index asc".equals(sort)) {
+        return 0; // test work around for SOLR-14595
+      }
+      
       switch(r.nextInt(10)) {
         case 0:
         case 1:
diff --git a/solr/core/src/test/org/apache/solr/search/facet/TestJsonFacetRefinement.java b/solr/core/src/test/org/apache/solr/search/facet/TestJsonFacetRefinement.java
index 1112f0b..babc91c 100644
--- a/solr/core/src/test/org/apache/solr/search/facet/TestJsonFacetRefinement.java
+++ b/solr/core/src/test/org/apache/solr/search/facet/TestJsonFacetRefinement.java
@@ -1472,4 +1472,47 @@ public class TestJsonFacetRefinement extends SolrTestCaseHS {
     } // end method loop
   }
 
+  @AwaitsFix(bugUrl="https://issues.apache.org/jira/browse/SOLR-14595")
+  public void testIndexAscRefineConsistency() throws Exception {
+    initServers();
+    final Client client = servers.getClient(random().nextInt());
+    client.queryDefaults().set("shards", servers.getShards(), "debugQuery", Boolean.toString(random().nextBoolean()));
+
+    List<SolrClient> clients = client.getClientProvider().all();
+    assertTrue(clients.size() >= 3);
+    final SolrClient c0 = clients.get(0);
+    final SolrClient c1 = clients.get(1);
+    final SolrClient c2 = clients.get(2);
+
+    client.deleteByQuery("*:*", null);
+    int id = 0;
+    
+    c0.add(sdoc("id", id++, "cat_s", "Z", "price_i", 10));
+    
+    c1.add(sdoc("id", id++, "cat_s", "Z", "price_i", -5000));
+    c1.add(sdoc("id", id++, "cat_s", "X", "price_i", 2,       "child_s", "A" ));
+    
+    c2.add(sdoc("id", id++, "cat_s", "X", "price_i", 2,       "child_s", "B" ));
+    c2.add(sdoc("id", id++, "cat_s", "X", "price_i", 2,       "child_s", "C" ));
+    
+    client.commit();
+
+    // TODO once SOLR-14595 is fixed, modify test to check full EnumSet, not just these two...
+    for (String m : Arrays.asList("smart", "enum")) {
+      client.testJQ(params("q", "*:*", "rows", "0", "json.facet", "{"
+                           + " cat : { type:terms, field:cat_s, limit:1, refine:true,"
+                           + "         overrequest:0, " // to trigger parent refinement given small data set
+                           + "         sort:'sum desc', "
+                           + "         facet: { sum : 'sum(price_i)', "
+                           + "                  child_"+m+" : { "
+                           + "                     type:terms, field:child_s, limit:1, refine:true,"
+                           + "                     sort:'index asc', method:" + m + " } "
+                           + "       }} }"
+                           )
+                    , "facets=={ count:5"
+                    + ", cat:{buckets:[ { val:X, count:3, sum:6.0, "
+                    + "                   child_"+m+":{buckets:[{val:A, count:1}]}}]}}"
+                    );
+    }
+  }
 }