mirror of https://github.com/apache/lucene.git
LUCENE-8815: Use a LogMergePolicy when the order of documents is important.
This commit is contained in:
parent
024e200bb9
commit
b7029b35d5
|
@ -19,6 +19,7 @@ package org.apache.lucene.document;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.lucene.index.IndexReader;
|
import org.apache.lucene.index.IndexReader;
|
||||||
|
import org.apache.lucene.index.IndexWriterConfig;
|
||||||
import org.apache.lucene.index.LeafReaderContext;
|
import org.apache.lucene.index.LeafReaderContext;
|
||||||
import org.apache.lucene.index.RandomIndexWriter;
|
import org.apache.lucene.index.RandomIndexWriter;
|
||||||
import org.apache.lucene.search.DoubleValues;
|
import org.apache.lucene.search.DoubleValues;
|
||||||
|
@ -31,7 +32,8 @@ public class TestFeatureDoubleValues extends LuceneTestCase {
|
||||||
|
|
||||||
public void testFeature() throws IOException {
|
public void testFeature() throws IOException {
|
||||||
Directory dir = newDirectory();
|
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();
|
Document doc = new Document();
|
||||||
doc.add(new FeatureField("field", "name", 30F));
|
doc.add(new FeatureField("field", "name", 30F));
|
||||||
writer.addDocument(doc);
|
writer.addDocument(doc);
|
||||||
|
@ -64,7 +66,8 @@ public class TestFeatureDoubleValues extends LuceneTestCase {
|
||||||
|
|
||||||
public void testFeatureMissing() throws IOException {
|
public void testFeatureMissing() throws IOException {
|
||||||
Directory dir = newDirectory();
|
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();
|
Document doc = new Document();
|
||||||
writer.addDocument(doc);
|
writer.addDocument(doc);
|
||||||
doc = new Document();
|
doc = new Document();
|
||||||
|
@ -95,7 +98,8 @@ public class TestFeatureDoubleValues extends LuceneTestCase {
|
||||||
|
|
||||||
public void testFeatureMissingFieldInSegment() throws IOException {
|
public void testFeatureMissingFieldInSegment() throws IOException {
|
||||||
Directory dir = newDirectory();
|
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();
|
Document doc = new Document();
|
||||||
writer.addDocument(doc);
|
writer.addDocument(doc);
|
||||||
writer.commit();
|
writer.commit();
|
||||||
|
@ -116,7 +120,8 @@ public class TestFeatureDoubleValues extends LuceneTestCase {
|
||||||
|
|
||||||
public void testFeatureMissingFeatureNameInSegment() throws IOException {
|
public void testFeatureMissingFeatureNameInSegment() throws IOException {
|
||||||
Directory dir = newDirectory();
|
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();
|
Document doc = new Document();
|
||||||
doc.add(new FeatureField("field", "different_name", 0.5F));
|
doc.add(new FeatureField("field", "different_name", 0.5F));
|
||||||
writer.addDocument(doc);
|
writer.addDocument(doc);
|
||||||
|
@ -138,7 +143,9 @@ public class TestFeatureDoubleValues extends LuceneTestCase {
|
||||||
|
|
||||||
public void testFeatureMultipleMissing() throws IOException {
|
public void testFeatureMultipleMissing() throws IOException {
|
||||||
Directory dir = newDirectory();
|
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();
|
Document doc = new Document();
|
||||||
writer.addDocument(doc);
|
writer.addDocument(doc);
|
||||||
doc = new Document();
|
doc = new Document();
|
||||||
|
|
Loading…
Reference in New Issue