Skip to content

Apache Lucene open-source search software

LUCENE-7574: Fix more index sorting test failures.

Adrien Grandd0b5d41f5c44
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexSorting.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexSorting.java
index eb74ab7b688..5ebf8f481d1 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexSorting.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexSorting.java
@@ -103,7 +103,10 @@ public class TestIndexSorting extends LuceneTestCase {
return new PointsWriter() {
@Override
public void merge(MergeState mergeState) throws IOException {
- assertEquals(needsIndexSort, mergeState.needsIndexSort);
+ // For single segment merge we cannot infer if the segment is already sorted or not.
+ if (mergeState.docMaps.length > 1) {
+ assertEquals(needsIndexSort, mergeState.needsIndexSort);
+ }
++ numCalls;
writer.merge(mergeState);
}