cpoerschke 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_r321730287
##########
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
Review comment:
These two tests after the `group sorted in a different way should fail`
comment are interesting:
* the comment suggests that failure is expected because of `sort/group.sort`
parameters but wouldn't it also fail because of the `group.limit=0` i.e. to
truely test about sorting the group.limit should be absent (default is 1) or
explicitly set to 1.
* eliminating the group.limit would give the queries below but shouldn't the
first of the two queries pass?
* query 1: if sort is present and group.sort is absent then sort would
also be used for group.sort -- it should pass?
* query 2: sort is absent and so the default is `sort=score` (I think) of
which the `group.sort` is not a prefix match -- it should fail.
```
assertSimpleQueryThrows(...,"sort", i1+" desc");
assertSimpleQueryThrows(..., "group.sort", i1+" desc");
```
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]