From 1c0f07ac03f0235adaf5c150f1c6656336e4282f Mon Sep 17 00:00:00 2001 From: Mayya Sharipova Date: Wed, 7 Oct 2020 11:01:49 -0400 Subject: [PATCH] LUCENE-9569 Disalbe sort opt on _doc (#1959) Sort optimization on _doc was introduced in PR #1856, but it looks unstable and lead to some recent tests failure. As the release of 8.7 is very soon, we need to temporarily disable this sort optimization for _doc for this release with a plan to stabilize it for later releases. --- .../org/apache/lucene/search/comparators/DocComparator.java | 5 ++++- .../lucene/search/TestFieldSortOptimizationSkipping.java | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lucene/core/src/java/org/apache/lucene/search/comparators/DocComparator.java b/lucene/core/src/java/org/apache/lucene/search/comparators/DocComparator.java index c0b3e2efdbdf..b9de45f3d983 100644 --- a/lucene/core/src/java/org/apache/lucene/search/comparators/DocComparator.java +++ b/lucene/core/src/java/org/apache/lucene/search/comparators/DocComparator.java @@ -40,8 +40,11 @@ public class DocComparator extends FieldComparator { /** Creates a new comparator based on document ids for {@code numHits} */ public DocComparator(int numHits, boolean reverse, int sortPost) { this.docIDs = new int[numHits]; + // Temporarily disable sort optimization for 8.7 release + this.enableSkipping = false; + // TODO: enable sort optimization after 8.7 release // skipping functionality is enabled if we are sorting by _doc in asc order as a primary sort - this.enableSkipping = (reverse == false && sortPost == 0); + // this.enableSkipping = (reverse == false && sortPost == 0); } @Override diff --git a/lucene/core/src/test/org/apache/lucene/search/TestFieldSortOptimizationSkipping.java b/lucene/core/src/test/org/apache/lucene/search/TestFieldSortOptimizationSkipping.java index 96e6ad941ebc..e8f2d8547d0b 100644 --- a/lucene/core/src/test/org/apache/lucene/search/TestFieldSortOptimizationSkipping.java +++ b/lucene/core/src/test/org/apache/lucene/search/TestFieldSortOptimizationSkipping.java @@ -321,6 +321,7 @@ public void testFloatSortOptimization() throws IOException { dir.close(); } + @AwaitsFix(bugUrl="https://issues.apache.org/jira/browse/LUCENE-9569") public void testDocSortOptimizationWithAfter() throws IOException { final Directory dir = newDirectory(); final IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig()); @@ -397,7 +398,7 @@ public void testDocSortOptimizationWithAfter() throws IOException { dir.close(); } - + @AwaitsFix(bugUrl="https://issues.apache.org/jira/browse/LUCENE-9569") public void testDocSortOptimization() throws IOException { final Directory dir = newDirectory(); final IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig());