From b7029b35d53e7b6611e1ba3869243436a4f89793 Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Thu, 27 Jun 2019 08:06:03 +0200 Subject: [PATCH] LUCENE-8815: Use a LogMergePolicy when the order of documents is important. --- .../document/TestFeatureDoubleValues.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lucene/core/src/test/org/apache/lucene/document/TestFeatureDoubleValues.java b/lucene/core/src/test/org/apache/lucene/document/TestFeatureDoubleValues.java index efdd04ec939..961afd19503 100644 --- a/lucene/core/src/test/org/apache/lucene/document/TestFeatureDoubleValues.java +++ b/lucene/core/src/test/org/apache/lucene/document/TestFeatureDoubleValues.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.LeafReaderContext; import org.apache.lucene.index.RandomIndexWriter; import org.apache.lucene.search.DoubleValues; @@ -31,7 +32,8 @@ public class TestFeatureDoubleValues 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", 30F)); writer.addDocument(doc); @@ -64,7 +66,8 @@ public class TestFeatureDoubleValues 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(); @@ -95,7 +98,8 @@ public class TestFeatureDoubleValues 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(); @@ -116,7 +120,8 @@ public class TestFeatureDoubleValues 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); @@ -138,7 +143,9 @@ public class TestFeatureDoubleValues 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); + System.out.println(writer.w.getConfig()); Document doc = new Document(); writer.addDocument(doc); doc = new Document();