mirror of https://github.com/apache/lucene.git
Fix intermittently failing TestSortedSetFieldSource (#12850)
This commit fixes the intermittently failing TestSortedSetFieldSource. The test assertions depend on doc order which may be affected by merging. The fix is to trivially avoid merging for the very small index, with just two docs.
This commit is contained in:
parent
6ba38c13eb
commit
7919133858
|
@ -22,7 +22,9 @@ import org.apache.lucene.document.Field;
|
|||
import org.apache.lucene.document.SortedSetDocValuesField;
|
||||
import org.apache.lucene.index.DirectoryReader;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.index.IndexWriterConfig;
|
||||
import org.apache.lucene.index.LeafReader;
|
||||
import org.apache.lucene.index.NoMergePolicy;
|
||||
import org.apache.lucene.queries.function.valuesource.SortedSetFieldSource;
|
||||
import org.apache.lucene.search.DocIdSetIterator;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
|
@ -31,13 +33,17 @@ import org.apache.lucene.search.ScoreMode;
|
|||
import org.apache.lucene.search.SortField;
|
||||
import org.apache.lucene.search.SortedSetSortField;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.tests.analysis.MockAnalyzer;
|
||||
import org.apache.lucene.tests.util.LuceneTestCase;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
|
||||
public class TestSortedSetFieldSource extends LuceneTestCase {
|
||||
public void testSimple() throws Exception {
|
||||
Directory dir = newDirectory();
|
||||
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(null));
|
||||
IndexWriterConfig conf = newIndexWriterConfig(new MockAnalyzer(random()));
|
||||
conf.setMaxBufferedDocs(2); // generate few segments
|
||||
conf.setMergePolicy(NoMergePolicy.INSTANCE); // prevent merges for this test
|
||||
IndexWriter writer = new IndexWriter(dir, conf);
|
||||
Document doc = new Document();
|
||||
doc.add(new SortedSetDocValuesField("value", new BytesRef("baz")));
|
||||
doc.add(newStringField("id", "2", Field.Store.YES));
|
||||
|
@ -47,7 +53,6 @@ public class TestSortedSetFieldSource extends LuceneTestCase {
|
|||
doc.add(new SortedSetDocValuesField("value", new BytesRef("bar")));
|
||||
doc.add(newStringField("id", "1", Field.Store.YES));
|
||||
writer.addDocument(doc);
|
||||
writer.forceMerge(1);
|
||||
writer.close();
|
||||
|
||||
DirectoryReader ir = DirectoryReader.open(dir);
|
||||
|
|
Loading…
Reference in New Issue