Disable sort optimization when index is sorted (#49727)
Don't run long sort optimization when index is already sorted on the same field as the sort query parameter. Relates to #37043, follow up for #48804
This commit is contained in:
parent
ad274dd797
commit
3bbaa01764
|
@ -413,6 +413,10 @@ public class QueryPhase implements SearchPhase {
|
|||
if (searchContext.collapse() != null) return null;
|
||||
if (searchContext.trackScores()) return null;
|
||||
if (searchContext.aggregations() != null) return null;
|
||||
if (canEarlyTerminate(reader, searchContext.sort())) {
|
||||
// disable this optimization if index sorting matches the query sort since it's already optimized by index searcher
|
||||
return null;
|
||||
}
|
||||
Sort sort = searchContext.sort().sort;
|
||||
SortField sortField = sort.getSort()[0];
|
||||
if (SortField.Type.LONG.equals(IndexSortConfig.getSortFieldType(sortField)) == false) return null;
|
||||
|
|
Loading…
Reference in New Issue