diff --git a/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java index 9c94bb61567..44942785cb5 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java +++ b/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java @@ -1092,6 +1092,11 @@ public abstract class BaseDocValuesFormatTestCase extends LuceneTestCase { public void testRandomSortedBytes() throws IOException { Directory dir = newDirectory(); IndexWriterConfig cfg = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())); + if (!defaultCodecSupportsDocsWithField()) { + // if the codec doesnt support missing, we expect missing to be mapped to byte[] + // by the impersonator, but we have to give it a chance to merge them to this + cfg.setMergePolicy(newLogMergePolicy()); + } RandomIndexWriter w = new RandomIndexWriter(random(), dir, cfg); int numDocs = atLeast(100); BytesRefHash hash = new BytesRefHash(); @@ -1123,6 +1128,11 @@ public abstract class BaseDocValuesFormatTestCase extends LuceneTestCase { if (rarely()) { w.commit(); } + if (!defaultCodecSupportsDocsWithField()) { + // if the codec doesnt support missing, we expect missing to be mapped to byte[] + // by the impersonator, but we have to give it a chance to merge them to this + w.forceMerge(1); + } for (int i = 0; i < numDocs; i++) { Document doc = new Document(); String id = "" + i + numDocs;