Skip to content

Commit

Permalink
Disable sort optimization when index is sorted (#49727)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mayya-sharipova committed Dec 2, 2019
1 parent e2ef2aa commit 8f42719
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,10 @@ private static Query tryRewriteLongSort(SearchContext searchContext, IndexReader
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;
Expand Down

0 comments on commit 8f42719

Please sign in to comment.