From 55e01279359d80f0675e0dee79ab55b4c0c520cd Mon Sep 17 00:00:00 2001 From: Dimitris Rempapis Date: Wed, 26 Mar 2025 15:34:18 +0200 Subject: [PATCH 1/3] Minor fixes based on late review --- .../xpack/lucene/bwc/codecs/BWCCodec.java | 2 -- .../bwc/codecs/lucene60/MetadataOnlyBKDReader.java | 12 ++++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/x-pack/plugin/old-lucene-versions/src/main/java/org/elasticsearch/xpack/lucene/bwc/codecs/BWCCodec.java b/x-pack/plugin/old-lucene-versions/src/main/java/org/elasticsearch/xpack/lucene/bwc/codecs/BWCCodec.java index f12935a2bec08..8e0f87eb3d00b 100644 --- a/x-pack/plugin/old-lucene-versions/src/main/java/org/elasticsearch/xpack/lucene/bwc/codecs/BWCCodec.java +++ b/x-pack/plugin/old-lucene-versions/src/main/java/org/elasticsearch/xpack/lucene/bwc/codecs/BWCCodec.java @@ -29,7 +29,6 @@ import org.apache.lucene.store.IOContext; import org.apache.lucene.util.Version; import org.elasticsearch.core.UpdateForV10; -import org.elasticsearch.xpack.lucene.bwc.codecs.lucene70.BWCLucene70Codec; import org.elasticsearch.xpack.lucene.bwc.codecs.lucene80.BWCLucene80Codec; import org.elasticsearch.xpack.lucene.bwc.codecs.lucene84.BWCLucene84Codec; import org.elasticsearch.xpack.lucene.bwc.codecs.lucene86.BWCLucene86Codec; @@ -229,7 +228,6 @@ private static Codec getBackwardCompatibleCodec(Codec codec) { if (codec == null) return null; return switch (codec.getClass().getSimpleName()) { - case "Lucene70Codec" -> new BWCLucene70Codec(); case "Lucene80Codec" -> new BWCLucene80Codec(); case "Lucene84Codec" -> new BWCLucene84Codec(); case "Lucene86Codec" -> new BWCLucene86Codec(); diff --git a/x-pack/plugin/old-lucene-versions/src/main/java/org/elasticsearch/xpack/lucene/bwc/codecs/lucene60/MetadataOnlyBKDReader.java b/x-pack/plugin/old-lucene-versions/src/main/java/org/elasticsearch/xpack/lucene/bwc/codecs/lucene60/MetadataOnlyBKDReader.java index ab865cba8722e..67fcb0df992af 100644 --- a/x-pack/plugin/old-lucene-versions/src/main/java/org/elasticsearch/xpack/lucene/bwc/codecs/lucene60/MetadataOnlyBKDReader.java +++ b/x-pack/plugin/old-lucene-versions/src/main/java/org/elasticsearch/xpack/lucene/bwc/codecs/lucene60/MetadataOnlyBKDReader.java @@ -86,8 +86,16 @@ public MetadataOnlyBKDReader(IndexInput metaIn, boolean isVersionPost86) throws pointCount = metaIn.readVLong(); docCount = metaIn.readVInt(); - // This code has been introduced to process IndexInput created with Lucene86Codec+. This is not necessary - // in the read-only version for older formats. + // The pre-8.6 code does not read the following fields that its standard Lucene counterpart does. After experimenting with the + // code, we got to the assumption that these are the last fields being read, which are not needed in the metadata-only reader, and + // we can safely ignore them when loading the file. Although by coincidence, nothing breaks if we read a couple of VLongs, as long + // as some bytes are available to read. + // + // The extra reads have been introduced to process IndexInput created with Lucene86Codec+, where a new BKD format has been + // introduced. It seems that we have stricter checks around the header and footer starting from the 86 formats hence we do need to + // consume all the data input there but not in previous formats. + // + // For correctness, we added version checking here. If and only if, the version is 8.6 or higher, we read the additional fields. if (isVersionPost86) { metaIn.readVInt(); metaIn.readLong(); From d58823047bb773e3f39d0c8f2b29a25a19ae5539 Mon Sep 17 00:00:00 2001 From: Dimitris Rempapis Date: Wed, 26 Mar 2025 15:37:46 +0200 Subject: [PATCH 2/3] Update docs/changelog/125666.yaml --- docs/changelog/125666.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 docs/changelog/125666.yaml diff --git a/docs/changelog/125666.yaml b/docs/changelog/125666.yaml new file mode 100644 index 0000000000000..bf629dde23a40 --- /dev/null +++ b/docs/changelog/125666.yaml @@ -0,0 +1,5 @@ +pr: 125666 +summary: Minor-Fixes Support 7x segments as archive in 8x / 9x +area: Search +type: bug +issues: [] From 6a8143abc2c6fad1449f68dc4b659df6497100d5 Mon Sep 17 00:00:00 2001 From: Dimitris Rempapis Date: Thu, 27 Mar 2025 15:03:12 +0200 Subject: [PATCH 3/3] update after review --- .../lucene/bwc/codecs/lucene60/MetadataOnlyBKDReader.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/old-lucene-versions/src/main/java/org/elasticsearch/xpack/lucene/bwc/codecs/lucene60/MetadataOnlyBKDReader.java b/x-pack/plugin/old-lucene-versions/src/main/java/org/elasticsearch/xpack/lucene/bwc/codecs/lucene60/MetadataOnlyBKDReader.java index 67fcb0df992af..b50ca32dd88ad 100644 --- a/x-pack/plugin/old-lucene-versions/src/main/java/org/elasticsearch/xpack/lucene/bwc/codecs/lucene60/MetadataOnlyBKDReader.java +++ b/x-pack/plugin/old-lucene-versions/src/main/java/org/elasticsearch/xpack/lucene/bwc/codecs/lucene60/MetadataOnlyBKDReader.java @@ -87,12 +87,12 @@ public MetadataOnlyBKDReader(IndexInput metaIn, boolean isVersionPost86) throws docCount = metaIn.readVInt(); // The pre-8.6 code does not read the following fields that its standard Lucene counterpart does. After experimenting with the - // code, we got to the assumption that these are the last fields being read, which are not needed in the metadata-only reader, and + // code, we got to the conclusion that these are the last fields being read, which are not needed in the metadata-only reader, and // we can safely ignore them when loading the file. Although by coincidence, nothing breaks if we read a couple of VLongs, as long // as some bytes are available to read. // // The extra reads have been introduced to process IndexInput created with Lucene86Codec+, where a new BKD format has been - // introduced. It seems that we have stricter checks around the header and footer starting from the 86 formats hence we do need to + // introduced. We have stricter checks around the header and footer starting from the 86 formats hence we do need to // consume all the data input there but not in previous formats. // // For correctness, we added version checking here. If and only if, the version is 8.6 or higher, we read the additional fields.