mirror of https://github.com/apache/lucene.git
Enable parent field in sorted bwc tests (#13067)
This enables the optional parent field in BWC tests from 9.10 on. This will need to be forward ported to main branch where the parent field is required to these tests since they add document blocks during tests.
This commit is contained in:
parent
6f026d7c36
commit
c42380cbd0
|
@ -55,6 +55,8 @@ public class TestIndexSortBackwardsCompatibility extends BackwardsCompatibilityT
|
|||
|
||||
static final String INDEX_NAME = "sorted";
|
||||
static final String SUFFIX = "";
|
||||
private static final Version FIRST_PARENT_DOC_VERSION = Version.LUCENE_9_10_0;
|
||||
private static final String PARENT_FIELD_NAME = "___parent";
|
||||
|
||||
public TestIndexSortBackwardsCompatibility(Version version, String pattern) {
|
||||
super(version, pattern);
|
||||
|
@ -79,8 +81,8 @@ public class TestIndexSortBackwardsCompatibility extends BackwardsCompatibilityT
|
|||
.setOpenMode(IndexWriterConfig.OpenMode.APPEND)
|
||||
.setIndexSort(sort)
|
||||
.setMergePolicy(newLogMergePolicy());
|
||||
if (this.version.onOrAfter(Version.LUCENE_10_0_0)) {
|
||||
indexWriterConfig.setParentField("___parent");
|
||||
if (this.version.onOrAfter(FIRST_PARENT_DOC_VERSION)) {
|
||||
indexWriterConfig.setParentField(PARENT_FIELD_NAME);
|
||||
}
|
||||
// open writer
|
||||
try (IndexWriter writer = new IndexWriter(directory, indexWriterConfig)) {
|
||||
|
@ -89,7 +91,10 @@ public class TestIndexSortBackwardsCompatibility extends BackwardsCompatibilityT
|
|||
Document child = new Document();
|
||||
child.add(new StringField("relation", "child", Field.Store.NO));
|
||||
child.add(new StringField("bid", "" + i, Field.Store.NO));
|
||||
child.add(new NumericDocValuesField("dateDV", i));
|
||||
if (version.onOrAfter(FIRST_PARENT_DOC_VERSION)
|
||||
== false) { // only add this to earlier versions
|
||||
child.add(new NumericDocValuesField("dateDV", i));
|
||||
}
|
||||
Document parent = new Document();
|
||||
parent.add(new StringField("relation", "parent", Field.Store.NO));
|
||||
parent.add(new StringField("bid", "" + i, Field.Store.NO));
|
||||
|
@ -158,6 +163,7 @@ public class TestIndexSortBackwardsCompatibility extends BackwardsCompatibilityT
|
|||
conf.setUseCompoundFile(false);
|
||||
conf.setCodec(TestUtil.getDefaultCodec());
|
||||
conf.setParentField("___parent");
|
||||
conf.setParentField(PARENT_FIELD_NAME);
|
||||
conf.setIndexSort(new Sort(new SortField("dateDV", SortField.Type.LONG, true)));
|
||||
IndexWriter writer = new IndexWriter(directory, conf);
|
||||
LineFileDocs docs = new LineFileDocs(new Random(0));
|
||||
|
|
Loading…
Reference in New Issue