diegoceccarelli commented on a change in pull request #300: SOLR-11831: Skip 
second grouping step if group.limit is 1 (aka Las Vegas Patch)
URL: https://github.com/apache/lucene-solr/pull/300#discussion_r327068468
 
 

 ##########
 File path: solr/core/src/test/org/apache/solr/TestDistributedGrouping.java
 ##########
 @@ -425,6 +426,65 @@ public void test() throws Exception {
     
     //Debug
     simpleQuery("q", "*:*", "rows", 10, "fl", "id," + i1, "group", "true", 
"group.field", i1, "debug", "true");
+    doTestGroupSkipSecondStep();
+  }
+
+  /*
+    SOLR-11831, test skipping the second grouping step if the query only 
retrieves on document per group
+   */
+  private void doTestGroupSkipSecondStep() throws Exception {
+    ignoreException(GroupParams.GROUP_SKIP_DISTRIBUTED_SECOND); // don't print 
stack trace for exception raised by group.skip.second.step
+    // Ignore numFound if group.skip.second.step is enabled because the number 
of documents per group will not be computed (will default to 1)
+    handle.put("numFound", SKIP);
+    query("q", "{!func}id_i1", "rows", 3, "group.skip.second.step", true, 
"group.limit", 1,  "fl",  "id," + i1, "group", "true",
+        "group.field", i1);
+    query("q", "kings", "group.skip.second.step", true, "fl", "id," + i1, 
"group", "true", "group.field", i1);
+    query("q", "{!func}id_i1", "rows", 3, "group.skip.second.step", true,  
"fl",  "id," + i1, "group", "true",
+        "group.field", i1);
+    query("q", "1234doesnotmatchanything1234", "group.skip.second.step", true, 
"fl", "id," + i1, "group", "true", "group.field", i1);
+
+    ignoreException("Illegal grouping specification");
+    // ngroups will return the corrent results, the problem is that numFound 
for each group might be wrong in case of multishard setting - but there is no 
way to
+    // enable/disable it.
+    //assertSimpleQueryThrows("q", "{!func}id_i1", "group.skip.second.step", 
true, "fl", "id," + i1, "group", "true", "group.field", i1, "group.ngroups", 
true);
+    assertSimpleQueryThrows("q", "{!func}id", "group.skip.second.step", true, 
"fl", "id," + i1, "group", "true", "group.field", i1, "group.limit", 5);
+    assertSimpleQueryThrows("q", "{!func}id_i1", "group.skip.second.step", 
true, "fl", "id," + i1, "group", "true", "group.field", i1, "group.limit", 0);
+    // group sorted in a different way should fail
+    assertSimpleQueryThrows("q", "{!func}id_i1", "group.skip.second.step", 
true, "fl", "id," + i1, "group", "true", "group.field", i1, "group.limit", 0, 
"sort", i1+" desc");
+    assertSimpleQueryThrows("q", "{!func}id_i1", "group.skip.second.step", 
true, "fl", "id," + i1, "group", "true", "group.field", i1, "group.limit", 0, 
"group.sort", i1+" desc");
+    query("q", "{!func}id_i1", "rows", 3, "group.skip.second.step", true,  
"fl",  "id," + i1, "group", "true",
+        "group.field", i1, "sort", tlong+" desc,"+i1+" asc", "group.sort", 
tlong+" desc");
+
+    query("q", "{!func}id_i1", "rows", 3, "group.skip.second.step", true,  
"fl",  "id," + i1, "group", "true",
+        "group.field", i1, "sort", tlong+" desc,"+i1+" asc", "group.sort", 
tlong+" desc");
+    query("q", "{!func}id_i1", "rows", 3, "group.skip.second.step", true,  
"fl",  "id," + i1, "group", "true",
+        "group.field", i1, "sort", tlong+" desc,"+i1+" asc", "group.sort", 
tlong+" desc,"+ i1+" asc");
+    // not a prefix, should fail
+    assertSimpleQueryThrows("q", "{!func}id_i1", "rows", 3, 
"group.skip.second.step", true,  "fl",  "id," + i1, "group", "true",
+        "group.field", i1, "sort", tlong+" desc,"+i1+" asc", "group.sort",i1+" 
asc,"+tlong+" desc");
+
+    // check group.main == true
 
 Review comment:
   Added more comments for `group.format == simple` but now I'm thinking: 
should we randomize the output format over the tests? 
   
   re `numFound`: I would keep it as it is, the reason is that when 
`group.skip.second.step` `numFound` is not reliable and we don't to compare it. 
It might not be returned atm but it might be in the future.. what do you think? 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to