From eff574f8b376f5a69a15f1944445b24cdc04b6b3 Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Fri, 5 Jul 2019 09:12:50 +0200 Subject: [PATCH] LUCENE-8803: Ensure doc ID order is preserved in tests. --- .../apache/lucene/document/TestFeatureSort.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lucene/core/src/test/org/apache/lucene/document/TestFeatureSort.java b/lucene/core/src/test/org/apache/lucene/document/TestFeatureSort.java index d1a39cff4ce..47e29c0cb28 100644 --- a/lucene/core/src/test/org/apache/lucene/document/TestFeatureSort.java +++ b/lucene/core/src/test/org/apache/lucene/document/TestFeatureSort.java @@ -19,6 +19,7 @@ package org.apache.lucene.document; import java.io.IOException; import org.apache.lucene.index.IndexReader; +import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.index.RandomIndexWriter; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; @@ -46,7 +47,8 @@ public class TestFeatureSort extends LuceneTestCase { public void testFeature() throws IOException { Directory dir = newDirectory(); - RandomIndexWriter writer = new RandomIndexWriter(random(), dir); + IndexWriterConfig config = newIndexWriterConfig().setMergePolicy(newLogMergePolicy(random().nextBoolean())); + RandomIndexWriter writer = new RandomIndexWriter(random(), dir, config); Document doc = new Document(); doc.add(new FeatureField("field", "name", 30.1F)); doc.add(newStringField("value", "30.1", Field.Store.YES)); @@ -78,7 +80,8 @@ public class TestFeatureSort extends LuceneTestCase { public void testFeatureMissing() throws IOException { Directory dir = newDirectory(); - RandomIndexWriter writer = new RandomIndexWriter(random(), dir); + IndexWriterConfig config = newIndexWriterConfig().setMergePolicy(newLogMergePolicy(random().nextBoolean())); + RandomIndexWriter writer = new RandomIndexWriter(random(), dir, config); Document doc = new Document(); writer.addDocument(doc); doc = new Document(); @@ -108,7 +111,8 @@ public class TestFeatureSort extends LuceneTestCase { public void testFeatureMissingFieldInSegment() throws IOException { Directory dir = newDirectory(); - RandomIndexWriter writer = new RandomIndexWriter(random(), dir); + IndexWriterConfig config = newIndexWriterConfig().setMergePolicy(newLogMergePolicy(random().nextBoolean())); + RandomIndexWriter writer = new RandomIndexWriter(random(), dir, config); Document doc = new Document(); writer.addDocument(doc); writer.commit(); @@ -139,7 +143,8 @@ public class TestFeatureSort extends LuceneTestCase { public void testFeatureMissingFeatureNameInSegment() throws IOException { Directory dir = newDirectory(); - RandomIndexWriter writer = new RandomIndexWriter(random(), dir); + IndexWriterConfig config = newIndexWriterConfig().setMergePolicy(newLogMergePolicy(random().nextBoolean())); + RandomIndexWriter writer = new RandomIndexWriter(random(), dir, config); Document doc = new Document(); doc.add(new FeatureField("field", "different_name", 0.5F)); writer.addDocument(doc); @@ -171,7 +176,8 @@ public class TestFeatureSort extends LuceneTestCase { public void testFeatureMultipleMissing() throws IOException { Directory dir = newDirectory(); - RandomIndexWriter writer = new RandomIndexWriter(random(), dir); + IndexWriterConfig config = newIndexWriterConfig().setMergePolicy(newLogMergePolicy(random().nextBoolean())); + RandomIndexWriter writer = new RandomIndexWriter(random(), dir, config); Document doc = new Document(); writer.addDocument(doc); doc = new Document();