Skip to content

Commit

Permalink
Forbid group.query and group.func
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoceccarelli committed Sep 26, 2019
1 parent a5c5e61 commit 8cbbb03
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion solr/solr-ref-guide/src/result-grouping.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<other-parsers.adoc#re-ranking-query-parser,Re-ranking Query Parser>>, 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 <<other-parsers.adoc#re-ranking-query-parser,Re-ranking Query Parser>>.
+
More details on `group.skip.second.step` in https://www.youtube.com/watch?v=eMuepJpjUjI&t=1591[Learning to Rank: From Theory to Production].

Expand Down

0 comments on commit 8cbbb03

Please sign in to comment.