Skip to content

Commit

Permalink
Update to Apache Lucene 9.4.0 (#4661)
Browse files Browse the repository at this point in the history
Signed-off-by: Andriy Redko <andriy.redko@aiven.io>

Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
  • Loading branch information
reta committed Oct 3, 2022
1 parent bd532e1 commit 7f14bc9
Show file tree
Hide file tree
Showing 55 changed files with 57 additions and 46 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Add index specific setting for remote repository ([#4253](https://github.com/opensearch-project/OpenSearch/pull/4253))
- [Segment Replication] Update replicas to commit SegmentInfos instead of relying on SIS files from primary shards. ([#4402](https://github.com/opensearch-project/OpenSearch/pull/4402))
- Change the version to remove deprecated code of adding node name into log pattern of log4j property file ([#4569](https://github.com/opensearch-project/OpenSearch/pull/4569))
- Update to Apache Lucene 9.4.0 ([#4661](https://github.com/opensearch-project/OpenSearch/pull/4661))

### Deprecated

Expand Down
2 changes: 1 addition & 1 deletion buildSrc/version.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
opensearch = 2.4.0
lucene = 9.3.0
lucene = 9.4.0

bundled_jdk_vendor = adoptium
bundled_jdk = 17.0.4+8
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
19749e264805171009836cbedecc5494b13cd920

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
aa0f250558375922f3091820361156e514fe1842

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
32eb1ad367ab1289804aeed95ea7216711a7764d

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
63661714be65f882a921d281965b0779fd487b90

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1034d876551fc21f7835b456dab01db21b9a4af6

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
f704ee4b14e2fe2622bb983f04b36a32df8fd4a7

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a95ff17b51da6b3da641fa4053e5ee9ea2ff5daf

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
13e1ae2c760d8c0d7990ffe3296e46d9d8e6f842
1 change: 0 additions & 1 deletion server/licenses/lucene-analysis-common-9.3.0.jar.sha1

This file was deleted.

1 change: 1 addition & 0 deletions server/licenses/lucene-analysis-common-9.4.0.jar.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
02fbd4e87241411fcf5d34e92a50bee46ab164dc
1 change: 0 additions & 1 deletion server/licenses/lucene-backward-codecs-9.3.0.jar.sha1

This file was deleted.

1 change: 1 addition & 0 deletions server/licenses/lucene-backward-codecs-9.4.0.jar.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
259863dfd107645de6146b3c87b4ecee66a4d43d
1 change: 0 additions & 1 deletion server/licenses/lucene-core-9.3.0.jar.sha1

This file was deleted.

1 change: 1 addition & 0 deletions server/licenses/lucene-core-9.4.0.jar.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cca1116f813c0f0c63acfac4c952baf29d46d76b
1 change: 0 additions & 1 deletion server/licenses/lucene-grouping-9.3.0.jar.sha1

This file was deleted.

1 change: 1 addition & 0 deletions server/licenses/lucene-grouping-9.4.0.jar.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
51bec1d5acc8ecaf9f50e047d3f86d60c7a958f4
1 change: 0 additions & 1 deletion server/licenses/lucene-highlighter-9.3.0.jar.sha1

This file was deleted.

1 change: 1 addition & 0 deletions server/licenses/lucene-highlighter-9.4.0.jar.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
c8cf8c9308d8fb18a927c7ed267a14ace3990a5f
1 change: 0 additions & 1 deletion server/licenses/lucene-join-9.3.0.jar.sha1

This file was deleted.

1 change: 1 addition & 0 deletions server/licenses/lucene-join-9.4.0.jar.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
99b2d3c8e137a6853a2503456897d47d4f18974b
1 change: 0 additions & 1 deletion server/licenses/lucene-memory-9.3.0.jar.sha1

This file was deleted.

1 change: 1 addition & 0 deletions server/licenses/lucene-memory-9.4.0.jar.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
881cb214e79da14de35cb0e8e6779d2722828a96
1 change: 0 additions & 1 deletion server/licenses/lucene-misc-9.3.0.jar.sha1

This file was deleted.

1 change: 1 addition & 0 deletions server/licenses/lucene-misc-9.4.0.jar.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a126123e482e6bf2e7aea670d221a2a39d3277dc
1 change: 0 additions & 1 deletion server/licenses/lucene-queries-9.3.0.jar.sha1

This file was deleted.

1 change: 1 addition & 0 deletions server/licenses/lucene-queries-9.4.0.jar.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fe74dbfe9dba9ee9ee2cb80f151fde97fb4efd12
1 change: 0 additions & 1 deletion server/licenses/lucene-queryparser-9.3.0.jar.sha1

This file was deleted.

1 change: 1 addition & 0 deletions server/licenses/lucene-queryparser-9.4.0.jar.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
13f108a8572fcf0670c7df3ba8dbe1076d0e0dbe
1 change: 0 additions & 1 deletion server/licenses/lucene-sandbox-9.3.0.jar.sha1

This file was deleted.

1 change: 1 addition & 0 deletions server/licenses/lucene-sandbox-9.4.0.jar.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e7a676a12ea50dcbf64564f4e4022f939f0a627d
1 change: 0 additions & 1 deletion server/licenses/lucene-spatial-extras-9.3.0.jar.sha1

This file was deleted.

1 change: 1 addition & 0 deletions server/licenses/lucene-spatial-extras-9.4.0.jar.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
84d956d1cb1458c51967af1c4acadd2a1f92634d
1 change: 0 additions & 1 deletion server/licenses/lucene-spatial3d-9.3.0.jar.sha1

This file was deleted.

1 change: 1 addition & 0 deletions server/licenses/lucene-spatial3d-9.4.0.jar.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
76887ca708f23b13613e45fb9e307c548b22c6da
1 change: 0 additions & 1 deletion server/licenses/lucene-suggest-9.3.0.jar.sha1

This file was deleted.

1 change: 1 addition & 0 deletions server/licenses/lucene-suggest-9.4.0.jar.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
406c9c539f262449d3b1e57e7bc4302efeecaf6c
2 changes: 1 addition & 1 deletion server/src/main/java/org/opensearch/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public class Version implements Comparable<Version>, ToXContentFragment {
public static final Version V_2_2_2 = new Version(2020299, org.apache.lucene.util.Version.LUCENE_9_3_0);
public static final Version V_2_3_0 = new Version(2030099, org.apache.lucene.util.Version.LUCENE_9_3_0);
public static final Version V_2_3_1 = new Version(2030199, org.apache.lucene.util.Version.LUCENE_9_3_0);
public static final Version V_2_4_0 = new Version(2040099, org.apache.lucene.util.Version.LUCENE_9_3_0);
public static final Version V_2_4_0 = new Version(2040099, org.apache.lucene.util.Version.LUCENE_9_4_0);
public static final Version CURRENT = V_2_4_0;

public static Version readVersion(StreamInput in) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@

import org.apache.logging.log4j.Logger;
import org.apache.lucene.codecs.Codec;
import org.apache.lucene.codecs.lucene92.Lucene92Codec;
import org.apache.lucene.codecs.lucene92.Lucene92Codec.Mode;
import org.apache.lucene.codecs.lucene94.Lucene94Codec;
import org.apache.lucene.codecs.lucene94.Lucene94Codec.Mode;
import org.opensearch.common.Nullable;
import org.opensearch.common.collect.MapBuilder;
import org.opensearch.index.mapper.MapperService;
Expand All @@ -62,8 +62,8 @@ public class CodecService {
public CodecService(@Nullable MapperService mapperService, Logger logger) {
final MapBuilder<String, Codec> codecs = MapBuilder.<String, Codec>newMapBuilder();
if (mapperService == null) {
codecs.put(DEFAULT_CODEC, new Lucene92Codec());
codecs.put(BEST_COMPRESSION_CODEC, new Lucene92Codec(Mode.BEST_COMPRESSION));
codecs.put(DEFAULT_CODEC, new Lucene94Codec());
codecs.put(BEST_COMPRESSION_CODEC, new Lucene94Codec(Mode.BEST_COMPRESSION));
} else {
codecs.put(DEFAULT_CODEC, new PerFieldMappingPostingFormatCodec(Mode.BEST_SPEED, mapperService, logger));
codecs.put(BEST_COMPRESSION_CODEC, new PerFieldMappingPostingFormatCodec(Mode.BEST_COMPRESSION, mapperService, logger));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import org.apache.lucene.codecs.Codec;
import org.apache.lucene.codecs.DocValuesFormat;
import org.apache.lucene.codecs.PostingsFormat;
import org.apache.lucene.codecs.lucene92.Lucene92Codec;
import org.apache.lucene.codecs.lucene94.Lucene94Codec;
import org.apache.lucene.codecs.lucene90.Lucene90DocValuesFormat;
import org.opensearch.common.lucene.Lucene;
import org.opensearch.index.mapper.CompletionFieldMapper;
Expand All @@ -53,7 +53,7 @@
*
* @opensearch.internal
*/
public class PerFieldMappingPostingFormatCodec extends Lucene92Codec {
public class PerFieldMappingPostingFormatCodec extends Lucene94Codec {
private final Logger logger;
private final MapperService mapperService;
private final DocValuesFormat dvFormat = new Lucene90DocValuesFormat();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.apache.lucene.index.SortedSetDocValues;
import org.apache.lucene.index.StoredFieldVisitor;
import org.apache.lucene.index.Terms;
import org.apache.lucene.index.VectorEncoding;
import org.apache.lucene.index.VectorSimilarityFunction;
import org.apache.lucene.index.VectorValues;
import org.apache.lucene.search.TopDocs;
Expand Down Expand Up @@ -84,6 +85,7 @@ public final class TranslogLeafReader extends LeafReader {
0,
0,
0,
VectorEncoding.FLOAT32,
VectorSimilarityFunction.EUCLIDEAN,
false
);
Expand All @@ -101,6 +103,7 @@ public final class TranslogLeafReader extends LeafReader {
0,
0,
0,
VectorEncoding.FLOAT32,
VectorSimilarityFunction.EUCLIDEAN,
false
);
Expand All @@ -118,6 +121,7 @@ public final class TranslogLeafReader extends LeafReader {
0,
0,
0,
VectorEncoding.FLOAT32,
VectorSimilarityFunction.EUCLIDEAN,
false
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.apache.lucene.search.FieldComparator;
import org.apache.lucene.search.Scorable;
import org.apache.lucene.search.SortField;
import org.apache.lucene.search.comparators.TermOrdValComparator;
import org.apache.lucene.util.BitSet;
import org.apache.lucene.util.BytesRef;
import org.opensearch.common.util.BigArrays;
Expand Down Expand Up @@ -99,8 +100,13 @@ public FieldComparator<?> newComparator(String fieldname, int numHits, boolean e
final boolean sortMissingLast = sortMissingLast(missingValue) ^ reversed;
final BytesRef missingBytes = (BytesRef) missingObject(missingValue, reversed);
if (indexFieldData instanceof IndexOrdinalsFieldData) {
return new FieldComparator.TermOrdValComparator(numHits, null, sortMissingLast) {

FieldComparator<?> cmp = new TermOrdValComparator(
numHits,
indexFieldData.getFieldName(),
sortMissingLast,
reversed,
enableSkipping
) {
@Override
protected SortedDocValues getSortedDocValues(LeafReaderContext context, String field) throws IOException {
final SortedSetDocValues values = ((IndexOrdinalsFieldData) indexFieldData).load(context).getOrdinalsValues();
Expand All @@ -121,13 +127,9 @@ protected SortedDocValues getSortedDocValues(LeafReaderContext context, String f
return new ReplaceMissing(selectedValues, missingBytes);
}
}

@Override
public void setScorer(Scorable scorer) {
BytesRefFieldComparatorSource.this.setScorer(scorer);
}

};
cmp.disableSkipping();
return cmp;
}

return new FieldComparator.TermValComparator(numHits, null, sortMissingLast) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.apache.lucene.index.IndexableFieldType;
import org.apache.lucene.index.StoredFieldVisitor;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.VectorEncoding;
import org.apache.lucene.index.VectorSimilarityFunction;
import org.opensearch.OpenSearchException;
import org.opensearch.common.Nullable;
Expand Down Expand Up @@ -326,6 +327,7 @@ private GetResult innerGetLoadFromStoredFields(
0,
0,
0,
VectorEncoding.FLOAT32,
VectorSimilarityFunction.EUCLIDEAN,
false
);
Expand Down
12 changes: 6 additions & 6 deletions server/src/test/java/org/opensearch/index/codec/CodecTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

import org.apache.logging.log4j.LogManager;
import org.apache.lucene.codecs.Codec;
import org.apache.lucene.codecs.lucene92.Lucene92Codec;
import org.apache.lucene.codecs.lucene94.Lucene94Codec;
import org.apache.lucene.codecs.lucene90.Lucene90StoredFieldsFormat;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.DirectoryReader;
Expand Down Expand Up @@ -65,21 +65,21 @@ public class CodecTests extends OpenSearchTestCase {
public void testResolveDefaultCodecs() throws Exception {
CodecService codecService = createCodecService();
assertThat(codecService.codec("default"), instanceOf(PerFieldMappingPostingFormatCodec.class));
assertThat(codecService.codec("default"), instanceOf(Lucene92Codec.class));
assertThat(codecService.codec("default"), instanceOf(Lucene94Codec.class));
}

public void testDefault() throws Exception {
Codec codec = createCodecService().codec("default");
assertStoredFieldsCompressionEquals(Lucene92Codec.Mode.BEST_SPEED, codec);
assertStoredFieldsCompressionEquals(Lucene94Codec.Mode.BEST_SPEED, codec);
}

public void testBestCompression() throws Exception {
Codec codec = createCodecService().codec("best_compression");
assertStoredFieldsCompressionEquals(Lucene92Codec.Mode.BEST_COMPRESSION, codec);
assertStoredFieldsCompressionEquals(Lucene94Codec.Mode.BEST_COMPRESSION, codec);
}

// write some docs with it, inspect .si to see this was the used compression
private void assertStoredFieldsCompressionEquals(Lucene92Codec.Mode expected, Codec actual) throws Exception {
private void assertStoredFieldsCompressionEquals(Lucene94Codec.Mode expected, Codec actual) throws Exception {
Directory dir = newDirectory();
IndexWriterConfig iwc = newIndexWriterConfig(null);
iwc.setCodec(actual);
Expand All @@ -91,7 +91,7 @@ private void assertStoredFieldsCompressionEquals(Lucene92Codec.Mode expected, Co
SegmentReader sr = (SegmentReader) ir.leaves().get(0).reader();
String v = sr.getSegmentInfo().info.getAttribute(Lucene90StoredFieldsFormat.MODE_KEY);
assertNotNull(v);
assertEquals(expected, Lucene92Codec.Mode.valueOf(v));
assertEquals(expected, Lucene94Codec.Mode.valueOf(v));
ir.close();
dir.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
package org.opensearch.index.engine;

import org.apache.lucene.codecs.PostingsFormat;
import org.apache.lucene.codecs.lucene92.Lucene92Codec;
import org.apache.lucene.codecs.lucene94.Lucene94Codec;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexWriter;
Expand Down Expand Up @@ -70,7 +70,7 @@ public void testExceptionsAreNotCached() {
public void testCompletionStatsCache() throws IOException, InterruptedException {
final IndexWriterConfig indexWriterConfig = newIndexWriterConfig();
final PostingsFormat postingsFormat = new Completion90PostingsFormat();
indexWriterConfig.setCodec(new Lucene92Codec() {
indexWriterConfig.setCodec(new Lucene94Codec() {
@Override
public PostingsFormat getPostingsFormatForField(String field) {
return postingsFormat; // all fields are suggest fields
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.StoredFieldVisitor;
import org.apache.lucene.index.VectorEncoding;
import org.apache.lucene.index.VectorSimilarityFunction;
import org.opensearch.index.mapper.MappedFieldType;
import org.opensearch.index.mapper.MapperService;
Expand Down Expand Up @@ -81,6 +82,7 @@ public void setUp() throws Exception {
0,
0,
0,
VectorEncoding.FLOAT32,
VectorSimilarityFunction.EUCLIDEAN,
false
);
Expand Down

0 comments on commit 7f14bc9

Please sign in to comment.