From 697cd494bff1d1c5ba694d4c49535a29152de83c Mon Sep 17 00:00:00 2001 From: Nhat Nguyen Date: Tue, 2 Jul 2019 10:53:25 -0400 Subject: [PATCH] Remove sort by primary term when reading soft-deletes (#43845) With Lucene rollback (#33473), we should never have more than one primary term for each sequence number. Therefore we don't have to sort by the primary term when reading soft-deletes. --- .../elasticsearch/index/engine/LuceneChangesSnapshot.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/index/engine/LuceneChangesSnapshot.java b/server/src/main/java/org/elasticsearch/index/engine/LuceneChangesSnapshot.java index cb0862ff131..bf5ecc3350a 100644 --- a/server/src/main/java/org/elasticsearch/index/engine/LuceneChangesSnapshot.java +++ b/server/src/main/java/org/elasticsearch/index/engine/LuceneChangesSnapshot.java @@ -211,11 +211,8 @@ final class LuceneChangesSnapshot implements Translog.Snapshot { private TopDocs searchOperations(ScoreDoc after) throws IOException { final Query rangeQuery = LongPoint.newRangeQuery(SeqNoFieldMapper.NAME, Math.max(fromSeqNo, lastSeenSeqNo), toSeqNo); - final Sort sortedBySeqNoThenByTerm = new Sort( - new SortField(SeqNoFieldMapper.NAME, SortField.Type.LONG), - new SortField(SeqNoFieldMapper.PRIMARY_TERM_NAME, SortField.Type.LONG, true) - ); - return indexSearcher.searchAfter(after, rangeQuery, searchBatchSize, sortedBySeqNoThenByTerm); + final Sort sortedBySeqNo = new Sort(new SortField(SeqNoFieldMapper.NAME, SortField.Type.LONG)); + return indexSearcher.searchAfter(after, rangeQuery, searchBatchSize, sortedBySeqNo); } private Translog.Operation readDocAsOp(int docIndex) throws IOException {