Skip to content

Commit a73ad24

Browse files
authored
Fix backport of #46731 (#52744)
This change fixes the incomplete backport of #46731 in 7.x (as of 7.5). We now check if `max_children` is set on the top level nested sort and fails with an exception if it's not the case. Relates #46731 Closes #52202
1 parent 37be695 commit a73ad24

File tree

3 files changed

+1
-13
lines changed

3 files changed

+1
-13
lines changed

server/src/main/java/org/elasticsearch/search/sort/FieldSortBuilder.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -476,10 +476,6 @@ private Nested nested(QueryShardContext context, MappedFieldType fieldType) thro
476476
throw new QueryShardException(context,
477477
"max_children is only supported on v6.5.0 or higher");
478478
}
479-
if (nestedSort.getNestedSort() != null && nestedSort.getMaxChildren() != Integer.MAX_VALUE) {
480-
throw new QueryShardException(context,
481-
"max_children is only supported on last level of nested sort");
482-
}
483479
validateMaxChildrenExistOnlyInTopLevelNestedSort(context, nestedSort);
484480
return resolveNested(context, nestedSort);
485481
}

server/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortBuilder.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ public BucketedSort buildBucketedSort(QueryShardContext context) throws IOExcept
605605
IndexGeoPointFieldData geoIndexFieldData = fieldData(context);
606606
Nested nested = nested(context);
607607

608-
// TODO implement the single point optimization above
608+
// TODO implement the single point optimization above
609609

610610
return comparatorSource(localPoints, localSortMode, geoIndexFieldData, nested)
611611
.newBucketedSort(context.bigArrays(), order, DocValueFormat.RAW);
@@ -670,10 +670,6 @@ private Nested nested(QueryShardContext context) throws IOException {
670670
throw new QueryShardException(context,
671671
"max_children is only supported on v6.5.0 or higher");
672672
}
673-
if (nestedSort.getNestedSort() != null && nestedSort.getMaxChildren() != Integer.MAX_VALUE) {
674-
throw new QueryShardException(context,
675-
"max_children is only supported on last level of nested sort");
676-
}
677673
validateMaxChildrenExistOnlyInTopLevelNestedSort(context, nestedSort);
678674
return resolveNested(context, nestedSort);
679675
}

server/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,6 @@ private IndexFieldData.XFieldComparatorSource fieldComparatorSource(QueryShardCo
332332
throw new QueryShardException(context,
333333
"max_children is only supported on v6.5.0 or higher");
334334
}
335-
if (nestedSort.getNestedSort() != null && nestedSort.getMaxChildren() != Integer.MAX_VALUE) {
336-
throw new QueryShardException(context,
337-
"max_children is only supported on last level of nested sort");
338-
}
339335
// new nested sorts takes priority
340336
validateMaxChildrenExistOnlyInTopLevelNestedSort(context, nestedSort);
341337
nested = resolveNested(context, nestedSort);

0 commit comments

Comments
 (0)