You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by si...@apache.org on 2024/02/13 10:57:14 UTC
(lucene) branch branch_9x updated: Enable parent field in sorted bwc tests (#13067)
This is an automated email from the ASF dual-hosted git repository.
simonw pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/lucene.git
The following commit(s) were added to refs/heads/branch_9x by this push:
new e51ca16de96 Enable parent field in sorted bwc tests (#13067)
e51ca16de96 is described below
commit e51ca16de96c45bdabfe2dd5457c25bbf9884f4c
Author: Simon Willnauer <si...@apache.org>
AuthorDate: Tue Feb 13 11:57:10 2024 +0100
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.
---
.../backward_index/TestIndexSortBackwardsCompatibility.java | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/lucene/backward-codecs/src/test/org/apache/lucene/backward_index/TestIndexSortBackwardsCompatibility.java b/lucene/backward-codecs/src/test/org/apache/lucene/backward_index/TestIndexSortBackwardsCompatibility.java
index e9157f2dfa0..79862ae643f 100644
--- a/lucene/backward-codecs/src/test/org/apache/lucene/backward_index/TestIndexSortBackwardsCompatibility.java
+++ b/lucene/backward-codecs/src/test/org/apache/lucene/backward_index/TestIndexSortBackwardsCompatibility.java
@@ -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,6 +81,9 @@ public class TestIndexSortBackwardsCompatibility extends BackwardsCompatibilityT
.setOpenMode(IndexWriterConfig.OpenMode.APPEND)
.setIndexSort(sort)
.setMergePolicy(newLogMergePolicy());
+ if (this.version.onOrAfter(FIRST_PARENT_DOC_VERSION)) {
+ indexWriterConfig.setParentField(PARENT_FIELD_NAME);
+ }
// open writer
try (IndexWriter writer = new IndexWriter(directory, indexWriterConfig)) {
// add 10 docs
@@ -86,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));
@@ -154,6 +162,7 @@ public class TestIndexSortBackwardsCompatibility extends BackwardsCompatibilityT
conf.setMergePolicy(mp);
conf.setUseCompoundFile(false);
conf.setCodec(TestUtil.getDefaultCodec());
+ 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));