Skip to content

Commit aa17ec6

Browse files
authored
Minor-Fixes Support 7x segments as archive in 8x / 9x (#125666) (#125781)
Minor fixes to support 7x segments as archive in 8x / 9x
1 parent e26ca25 commit aa17ec6

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

docs/changelog/125666.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 125666
2+
summary: Minor-Fixes Support 7x segments as archive in 8x / 9x
3+
area: Search
4+
type: bug
5+
issues: []

x-pack/plugin/old-lucene-versions/src/main/java/org/elasticsearch/xpack/lucene/bwc/codecs/BWCCodec.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.apache.lucene.store.IOContext;
3030
import org.apache.lucene.util.Version;
3131
import org.elasticsearch.core.UpdateForV10;
32-
import org.elasticsearch.xpack.lucene.bwc.codecs.lucene70.BWCLucene70Codec;
3332
import org.elasticsearch.xpack.lucene.bwc.codecs.lucene80.BWCLucene80Codec;
3433
import org.elasticsearch.xpack.lucene.bwc.codecs.lucene84.BWCLucene84Codec;
3534
import org.elasticsearch.xpack.lucene.bwc.codecs.lucene86.BWCLucene86Codec;
@@ -229,7 +228,6 @@ private static Codec getBackwardCompatibleCodec(Codec codec) {
229228
if (codec == null) return null;
230229

231230
return switch (codec.getClass().getSimpleName()) {
232-
case "Lucene70Codec" -> new BWCLucene70Codec();
233231
case "Lucene80Codec" -> new BWCLucene80Codec();
234232
case "Lucene84Codec" -> new BWCLucene84Codec();
235233
case "Lucene86Codec" -> new BWCLucene86Codec();

x-pack/plugin/old-lucene-versions/src/main/java/org/elasticsearch/xpack/lucene/bwc/codecs/lucene60/MetadataOnlyBKDReader.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,16 @@ public MetadataOnlyBKDReader(IndexInput metaIn, boolean isVersionPost86) throws
8686
pointCount = metaIn.readVLong();
8787
docCount = metaIn.readVInt();
8888

89-
// This code has been introduced to process IndexInput created with Lucene86Codec+. This is not necessary
90-
// in the read-only version for older formats.
89+
// The pre-8.6 code does not read the following fields that its standard Lucene counterpart does. After experimenting with the
90+
// code, we got to the conclusion that these are the last fields being read, which are not needed in the metadata-only reader, and
91+
// we can safely ignore them when loading the file. Although by coincidence, nothing breaks if we read a couple of VLongs, as long
92+
// as some bytes are available to read.
93+
//
94+
// The extra reads have been introduced to process IndexInput created with Lucene86Codec+, where a new BKD format has been
95+
// introduced. We have stricter checks around the header and footer starting from the 86 formats hence we do need to
96+
// consume all the data input there but not in previous formats.
97+
//
98+
// For correctness, we added version checking here. If and only if, the version is 8.6 or higher, we read the additional fields.
9199
if (isVersionPost86) {
92100
metaIn.readVInt();
93101
metaIn.readLong();

0 commit comments

Comments
 (0)