Skip to content

Commit

Permalink
Remove sort by primary term when reading soft-deletes (#43845)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dnhatn committed Jul 2, 2019
1 parent 1ea5397 commit 697cd49
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,8 @@ private void fillParallelArray(ScoreDoc[] scoreDocs, ParallelArray parallelArray

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 {
Expand Down

0 comments on commit 697cd49

Please sign in to comment.