Skip to content

Commit e6c7f59

Browse files
committed
Update to Apache Lucene 10 for 3.0.0
Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
1 parent 4b284c5 commit e6c7f59

File tree

159 files changed

+781
-380
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+781
-380
lines changed

.github/workflows/assemble.yml

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ${{ matrix.os }}
88
strategy:
99
matrix:
10-
java: [ 11, 17, 21 ]
10+
java: [ 21, 23 ]
1111
os: [ubuntu-latest, windows-latest, macos-13]
1212
steps:
1313
- uses: actions/checkout@v4
@@ -16,17 +16,6 @@ jobs:
1616
with:
1717
java-version: ${{ matrix.java }}
1818
distribution: temurin
19-
- name: Set up JDK 17
20-
# See please https://docs.gradle.org/8.10/userguide/upgrading_version_8.html#minimum_daemon_jvm_version
21-
if: matrix.java == 11
22-
uses: actions/setup-java@v4
23-
with:
24-
java-version: 17
25-
distribution: temurin
26-
- name: Set JAVA${{ matrix.java }}_HOME
27-
shell: bash
28-
run: |
29-
echo "JAVA${{ matrix.java }}_HOME=$JAVA_HOME_${{ matrix.java }}_${{ runner.arch }}" >> $GITHUB_ENV
3019
- name: Setup docker (missing on MacOS)
3120
id: setup_docker
3221
if: runner.os == 'macos'
@@ -47,8 +36,8 @@ jobs:
4736
shell: bash
4837
if: runner.os != 'macos'
4938
run: |
50-
./gradlew assemble --parallel --no-build-cache -PDISABLE_BUILD_CACHE -Druntime.java=${{ matrix.java }}
39+
./gradlew assemble --parallel --no-build-cache -PDISABLE_BUILD_CACHE
5140
- name: Run Gradle (assemble)
5241
if: runner.os == 'macos' && steps.setup_docker.outcome == 'success'
5342
run: |
54-
./gradlew assemble --parallel --no-build-cache -PDISABLE_BUILD_CACHE -Druntime.java=${{ matrix.java }}
43+
./gradlew assemble --parallel --no-build-cache -PDISABLE_BUILD_CACHE

.github/workflows/precommit.yml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ${{ matrix.os }}
88
strategy:
99
matrix:
10-
java: [ 11, 17, 21, 23 ]
10+
java: [ 21, 23 ]
1111
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
1212
steps:
1313
- uses: actions/checkout@v4
@@ -17,18 +17,7 @@ jobs:
1717
java-version: ${{ matrix.java }}
1818
distribution: temurin
1919
cache: gradle
20-
- name: Set up JDK 17
21-
# See please https://docs.gradle.org/8.10/userguide/upgrading_version_8.html#minimum_daemon_jvm_version
22-
if: matrix.java == 11
23-
uses: actions/setup-java@v4
24-
with:
25-
java-version: 17
26-
distribution: temurin
27-
- name: Set JAVA${{ matrix.java }}_HOME
28-
shell: bash
29-
run: |
30-
echo "JAVA${{ matrix.java }}_HOME=$JAVA_HOME_${{ matrix.java }}_${{ runner.arch }}" >> $GITHUB_ENV
3120
- name: Run Gradle (precommit)
3221
shell: bash
3322
run: |
34-
./gradlew javadoc precommit --parallel -Druntime.java=${{ matrix.java }}
23+
./gradlew javadoc precommit --parallel

buildSrc/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ if (project != rootProject) {
171171

172172
allprojects {
173173
java {
174-
targetCompatibility = JavaVersion.VERSION_11
175-
sourceCompatibility = JavaVersion.VERSION_11
174+
targetCompatibility = JavaVersion.VERSION_21
175+
sourceCompatibility = JavaVersion.VERSION_21
176176
}
177177
}
178178

buildSrc/reaper/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
apply plugin: 'java'
1313

1414
java {
15-
targetCompatibility = JavaVersion.VERSION_11
16-
sourceCompatibility = JavaVersion.VERSION_11
15+
targetCompatibility = JavaVersion.VERSION_21
16+
sourceCompatibility = JavaVersion.VERSION_21
1717
}
1818

1919
jar {

buildSrc/src/testKit/thirdPartyAudit/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ dependencies {
4646
}
4747

4848
tasks.register("empty", ThirdPartyAuditTask) {
49-
targetCompatibility = JavaVersion.VERSION_11
49+
targetCompatibility = JavaVersion.VERSION_21
5050
signatureFile = file('third-party-audit-empty.txt')
5151
}
5252

5353
tasks.register("absurd", ThirdPartyAuditTask) {
54-
targetCompatibility = JavaVersion.VERSION_11
54+
targetCompatibility = JavaVersion.VERSION_21
5555
signatureFile = file('third-party-audit-absurd.txt')
5656
}

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[versions]
22
opensearch = "3.0.0"
3-
lucene = "9.12.0"
3+
lucene = "10.0.0"
44

55
bundled_jdk_vendor = "adoptium"
66
bundled_jdk = "23.0.1+11"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
5a9b3f728041df5b054aaaed3c3fd7ff0fed8ee7

libs/core/licenses/lucene-core-9.12.0.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.

libs/core/src/main/java/org/opensearch/LegacyESVersion.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class LegacyESVersion extends Version {
5050

5151
public static final LegacyESVersion V_6_0_0 = new LegacyESVersion(6000099, org.apache.lucene.util.Version.fromBits(7, 0, 0));
5252
public static final LegacyESVersion V_6_5_0 = new LegacyESVersion(6050099, org.apache.lucene.util.Version.fromBits(7, 0, 0));
53-
public static final LegacyESVersion V_7_2_0 = new LegacyESVersion(7020099, org.apache.lucene.util.Version.LUCENE_8_0_0);
53+
public static final LegacyESVersion V_7_2_0 = new LegacyESVersion(7020099, org.apache.lucene.util.Version.fromBits(8, 0, 0));
5454

5555
// todo move back to Version.java if retiring legacy version support
5656
protected static final Map<Integer, Version> idToVersion;

libs/core/src/main/java/org/opensearch/Version.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ public class Version implements Comparable<Version>, ToXContentFragment {
112112
public static final Version V_2_17_1 = new Version(2170199, org.apache.lucene.util.Version.LUCENE_9_11_1);
113113
public static final Version V_2_17_2 = new Version(2170299, org.apache.lucene.util.Version.LUCENE_9_11_1);
114114
public static final Version V_2_18_0 = new Version(2180099, org.apache.lucene.util.Version.LUCENE_9_12_0);
115-
public static final Version V_3_0_0 = new Version(3000099, org.apache.lucene.util.Version.LUCENE_9_12_0);
116115
public static final Version V_2_19_0 = new Version(2190099, org.apache.lucene.util.Version.LUCENE_9_12_0);
116+
public static final Version V_3_0_0 = new Version(3000099, org.apache.lucene.util.Version.LUCENE_10_0_0);
117117
public static final Version CURRENT = V_3_0_0;
118118

119119
public static Version fromId(int id) {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
89b26348ec305598fc224cc9583939564b67b2cf

modules/lang-expression/licenses/lucene-expressions-9.12.0.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
082c38c1335c069a73622c37ca3d39e64c1b2d33

plugins/analysis-icu/licenses/lucene-analysis-icu-9.12.0.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
26071742008630779523d08c0b46b2f371ef23a0

plugins/analysis-kuromoji/licenses/lucene-analysis-kuromoji-9.12.0.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4a6ff02a1bd34a3c0165da05f714bb8188074bdc

plugins/analysis-nori/licenses/lucene-analysis-nori-9.12.0.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4c488697df5038a78e5e65bb9b6da120af62d824

plugins/analysis-phonetic/licenses/lucene-analysis-phonetic-9.12.0.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1137b9846ec000b49c70c3fe5f8cd79b7129be22

plugins/analysis-smartcn/licenses/lucene-analysis-smartcn-9.12.0.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3fd86db5e9748063369db4bed84f1bd2ca62d387

plugins/analysis-stempel/licenses/lucene-analysis-stempel-9.12.0.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4e6b940b3b934d6de174fedaaeaefd647698648d

plugins/analysis-ukrainian/licenses/lucene-analysis-morfologik-9.12.0.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
13eb016bab14973158554a2e6cdf2abbc5c3eda1

server/licenses/lucene-analysis-common-9.12.0.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8e21f708eb1bbb71ce79cbfea093b6ca913f4abf

server/licenses/lucene-backward-codecs-9.12.0.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
5a9b3f728041df5b054aaaed3c3fd7ff0fed8ee7

server/licenses/lucene-core-9.12.0.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
17145d786d31e7ecd68d149ccc3e7ab83270f282

server/licenses/lucene-grouping-9.12.0.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
b8324f1b859620912c186b27d9666215ce3d258b

server/licenses/lucene-highlighter-9.12.0.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3a4c5bf84c855b011e740f30cb8a23f2ee85e1c1

server/licenses/lucene-join-9.12.0.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bc0f37a0a06b445555d07e5fe199d73436d51352

server/licenses/lucene-memory-9.12.0.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
5f619b32c62bb9405e7af595cf7311113ed62e33

server/licenses/lucene-misc-9.12.0.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3d2f98787e27e8e2a65d994c86563edf16dd92f1

server/licenses/lucene-queries-9.12.0.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
e11886c913058ef20378715dee715d942d04babc

server/licenses/lucene-queryparser-9.12.0.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1795ce5b066bda61483c375f6b8e358aaa4f6348

server/licenses/lucene-sandbox-9.12.0.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
a701eb363cf0a75ebacd1844398314250abcf592

server/licenses/lucene-spatial-extras-9.12.0.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
d9e0a8a6084d7657a633c1aa94d750414f5288c4

server/licenses/lucene-spatial3d-9.12.0.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
d79099abc148a1906e129abbabd5e1b18a20c117

server/licenses/lucene-suggest-9.12.0.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.

server/src/main/java/org/apache/lucene/codecs/lucene90/Lucene90DocValuesConsumerWrapper.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,20 @@ public class Lucene90DocValuesConsumerWrapper implements Closeable {
2727

2828
public Lucene90DocValuesConsumerWrapper(
2929
SegmentWriteState state,
30+
int skipIndexIntervalSize,
3031
String dataCodec,
3132
String dataExtension,
3233
String metaCodec,
3334
String metaExtension
3435
) throws IOException {
35-
lucene90DocValuesConsumer = new Lucene90DocValuesConsumer(state, dataCodec, dataExtension, metaCodec, metaExtension);
36+
lucene90DocValuesConsumer = new Lucene90DocValuesConsumer(
37+
state,
38+
skipIndexIntervalSize,
39+
dataCodec,
40+
dataExtension,
41+
metaCodec,
42+
metaExtension
43+
);
3644
}
3745

3846
public Lucene90DocValuesConsumer getLucene90DocValuesConsumer() {

server/src/main/java/org/apache/lucene/queries/BinaryDocValuesRangeQuery.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.apache.lucene.search.QueryVisitor;
4343
import org.apache.lucene.search.ScoreMode;
4444
import org.apache.lucene.search.Scorer;
45+
import org.apache.lucene.search.ScorerSupplier;
4546
import org.apache.lucene.search.TwoPhaseIterator;
4647
import org.apache.lucene.search.Weight;
4748
import org.apache.lucene.util.BytesRef;
@@ -84,7 +85,7 @@ public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float bo
8485
return new ConstantScoreWeight(this, boost) {
8586

8687
@Override
87-
public Scorer scorer(LeafReaderContext context) throws IOException {
88+
public ScorerSupplier scorerSupplier(LeafReaderContext context) throws IOException {
8889
final BinaryDocValues values = context.reader().getBinaryDocValues(fieldName);
8990
if (values == null) {
9091
return null;
@@ -129,7 +130,9 @@ public float matchCost() {
129130
return 4; // at most 4 comparisons
130131
}
131132
};
132-
return new ConstantScoreScorer(this, score(), scoreMode, iterator);
133+
134+
final Scorer scorer = new ConstantScoreScorer(score(), scoreMode, iterator);
135+
return new DefaultScorerSupplier(scorer);
133136
}
134137

135138
@Override

server/src/main/java/org/apache/lucene/queries/BlendedTermQuery.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import org.apache.lucene.search.QueryVisitor;
4848
import org.apache.lucene.search.TermQuery;
4949
import org.apache.lucene.util.ArrayUtil;
50+
import org.apache.lucene.util.IOSupplier;
5051
import org.apache.lucene.util.InPlaceMergeSorter;
5152

5253
import java.io.IOException;
@@ -208,7 +209,12 @@ private TermStates adjustTTF(IndexReaderContext readerContext, TermStates termCo
208209
int df = termContext.docFreq();
209210
long ttf = sumTTF;
210211
for (int i = 0; i < len; i++) {
211-
TermState termState = termContext.get(leaves.get(i));
212+
final IOSupplier<TermState> termStateSupplier = termContext.get(leaves.get(i));
213+
if (termStateSupplier == null) {
214+
continue;
215+
}
216+
217+
final TermState termState = termStateSupplier.get();
212218
if (termState == null) {
213219
continue;
214220
}
@@ -232,10 +238,16 @@ private static TermStates adjustDF(IndexReaderContext readerContext, TermStates
232238
}
233239
TermStates newCtx = new TermStates(readerContext);
234240
for (int i = 0; i < len; ++i) {
235-
TermState termState = ctx.get(leaves.get(i));
241+
final IOSupplier<TermState> termStateSupplier = ctx.get(leaves.get(i));
242+
if (termStateSupplier == null) {
243+
continue;
244+
}
245+
246+
final TermState termState = termStateSupplier.get();
236247
if (termState == null) {
237248
continue;
238249
}
250+
239251
newCtx.register(termState, i, newDocFreq, newTTF);
240252
newDocFreq = 0;
241253
newTTF = 0;
@@ -385,7 +397,7 @@ protected Query topLevelQuery(Term[] terms, TermStates[] ctx, int[] docFreqs, in
385397
if (low.clauses().isEmpty()) {
386398
BooleanQuery.Builder queryBuilder = new BooleanQuery.Builder();
387399
for (BooleanClause booleanClause : high) {
388-
queryBuilder.add(booleanClause.getQuery(), Occur.MUST);
400+
queryBuilder.add(booleanClause.query(), Occur.MUST);
389401
}
390402
return queryBuilder.build();
391403
} else if (high.clauses().isEmpty()) {

server/src/main/java/org/apache/lucene/search/grouping/CollapseTopFieldDocs.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,10 @@ public static CollapseTopFieldDocs merge(Sort sort, int start, int size, Collaps
192192
final CollapseTopFieldDocs shard = shardHits[shardIDX];
193193
// totalHits can be non-zero even if no hits were
194194
// collected, when searchAfter was used:
195-
totalHitCount += shard.totalHits.value;
195+
totalHitCount += shard.totalHits.value();
196196
// If any hit count is a lower bound then the merged
197197
// total hit count is a lower bound as well
198-
if (shard.totalHits.relation == TotalHits.Relation.GREATER_THAN_OR_EQUAL_TO) {
198+
if (shard.totalHits.relation() == TotalHits.Relation.GREATER_THAN_OR_EQUAL_TO) {
199199
totalHitsRelation = TotalHits.Relation.GREATER_THAN_OR_EQUAL_TO;
200200
}
201201
if (CollectionUtils.isEmpty(shard.scoreDocs) == false) {

server/src/main/java/org/apache/lucene/search/grouping/CollapsingDocValuesSource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public void setNextReader(LeafReaderContext readerContext) throws IOException {
229229
public boolean advanceExact(int target) throws IOException {
230230
if (sorted.advanceExact(target)) {
231231
ord = (int) sorted.nextOrd();
232-
if (sorted.nextOrd() != SortedSetDocValues.NO_MORE_ORDS) {
232+
if (sorted.nextOrd() != SortedSetDocValues.NO_MORE_DOCS) {
233233
throw new IllegalStateException(
234234
"failed to collapse " + target + ", the collapse field must be single valued"
235235
);

0 commit comments

Comments
 (0)