diff --git a/solr/core/src/java/org/apache/solr/search/grouping/GroupingSpecification.java b/solr/core/src/java/org/apache/solr/search/grouping/GroupingSpecification.java index e8b10b62c2e1..18cdba004f7c 100644 --- a/solr/core/src/java/org/apache/solr/search/grouping/GroupingSpecification.java +++ b/solr/core/src/java/org/apache/solr/search/grouping/GroupingSpecification.java @@ -76,10 +76,16 @@ private void validateSkipSecondGroupingStep() { GroupParams.GROUP_LIMIT + " != 1 ("+GroupParams.GROUP_LIMIT+" is "+limit+")"); } + // group.func not supported if (functions.length > 0){ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, GroupParams.GROUP_SKIP_DISTRIBUTED_SECOND + " does not support "+ GroupParams.GROUP_FUNC); } + // group.query not supported + if (queries.length > 0){ + throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, + GroupParams.GROUP_SKIP_DISTRIBUTED_SECOND + " does not support "+ GroupParams.GROUP_QUERY); + } if (offset != 0) { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, diff --git a/solr/core/src/test/org/apache/solr/TestDistributedGrouping.java b/solr/core/src/test/org/apache/solr/TestDistributedGrouping.java index 4f4d55d802a6..7f26882121a7 100644 --- a/solr/core/src/test/org/apache/solr/TestDistributedGrouping.java +++ b/solr/core/src/test/org/apache/solr/TestDistributedGrouping.java @@ -517,6 +517,10 @@ private void doTestGroupSkipSecondStep() throws Exception { assertSimpleQueryThrows("q", "{!func}id_i1", "rows", 3, "group.skip.second.step", true, "fl", "id," + i1, "group", "true", "group.func", i1); + // check that the requests fails if group.query is used with group.skip.second.step instead of group.field + assertSimpleQueryThrows("q", "{!func}id_i1", "rows", 3, "group.skip.second.step", true, "fl", "id," + i1, "group", "true", + "group.query", "{!func}id_1"); + /// check that group.skip.second.step works properly with group.main == true (using a different // EndResultTransformer but still sharing the skipping logic) query("q", "{!func}id_i1", "rows", 3, "group.skip.second.step", true, "fl", "id," + i1, "group", "true", @@ -533,6 +537,7 @@ private void doTestGroupSkipSecondStep() throws Exception { query("q", "{!func}id_i1", "rows", "3", "group.skip.second.step", "true", "fl", "id," + i1+",id_i1,score", "group", "true", "group.field", i1, "group.limit", "1"); query("q", "{!func}id_i1", "rows", "3", "group.skip.second.step", "false", "fl", "id," + i1+",id_i1,score", "group", "true", "group.field", i1, "group.limit", "1"); + assertNumFoundWithSkipSecondGroupingStep("q", "kings", "group.skip.second.step", "true", "fl", "id," + i1, "group", "true", "group.field", i1); assertNumFoundWithSkipSecondGroupingStep( "q", "{!func}id_i1", "rows", "3", "fl", "id," + i1+",id_i1", "group", "true", "group.field", i1, "group.limit", "1","sort", tlong+" desc"); assertNumFoundWithSkipSecondGroupingStep("q", "{!func}id_i1", "rows", "3", "fl", "id," + i1+",id_i1,score", "group", "true", "group.field", i1, "group.limit", "1"); diff --git a/solr/solr-ref-guide/src/result-grouping.adoc b/solr/solr-ref-guide/src/result-grouping.adoc index 81a08c0e781a..d99b782fbdc5 100644 --- a/solr/solr-ref-guide/src/result-grouping.adoc +++ b/solr/solr-ref-guide/src/result-grouping.adoc @@ -115,7 +115,7 @@ Setting this parameter to a number greater than 0 enables caching for result gro Testing has shown that group caching only improves search time with Boolean, wildcard, and fuzzy queries. For simple queries like term or "match all" queries, group caching degrades performance. `group.skip.second.step`:: -This parameter can be set to `true` if only one document per group needs to be retrieved. Result Grouping executes two searches; if enabled this option will disable the second search improving the performance. By default the value is set to `false`. It can be set to `true` if `group.limit` is 1, and `group.sort` fields list is absent or is a prefix of `sort` fields list (e.g., if `sort=price asc,name desc` and `group.sort=price asc` is fine, but `sort=price asc,name desc` and `group.sort=name desc` is not). When enabled it will not be possible to know `numFound` for each group - `numFound` will be set to one. It cannot be used together with <>, and together with `group.func` - group based on function (not supported in distribute mode). +This parameter can be set to `true` if only one document per group needs to be retrieved. Result Grouping executes two searches; if enabled this option will disable the second search improving the performance. By default the value is set to `false`. It can be set to `true` if `group.limit` is 1, and `group.sort` fields list is absent or is a prefix of `sort` fields list (e.g., if `sort=price asc,name desc` and `group.sort=price asc` is fine, but `sort=price asc,name desc` and `group.sort=name desc` is not). When grouping only grouping by field is supported (`group.field`), grouping by function (`group.func`) or query (`group.query`) are not supported. The actual `numFound` for each group will not be available, `numFound` will be set to 1. It cannot be used together with <>. + More details on `group.skip.second.step` in https://www.youtube.com/watch?v=eMuepJpjUjI&t=1591[Learning to Rank: From Theory to Production].