diff --git a/build-tools-internal/version.properties b/build-tools-internal/version.properties
index 29cd82ca60d81..24f1c603f9282 100644
--- a/build-tools-internal/version.properties
+++ b/build-tools-internal/version.properties
@@ -1,5 +1,5 @@
elasticsearch = 9.1.0
-lucene = 10.2.1-snapshot-ae6484f43e6
+lucene = 10.2.1
bundled_jdk_vendor = openjdk
bundled_jdk = 24+36@1f9ff9062db4449d8ca828c504ffae90
diff --git a/docs/changelog/127343.yaml b/docs/changelog/127343.yaml
new file mode 100644
index 0000000000000..3d3e12799d163
--- /dev/null
+++ b/docs/changelog/127343.yaml
@@ -0,0 +1,5 @@
+pr: 127343
+summary: Upgrade to Lucene 10.2.1
+area: Search
+type: upgrade
+issues: []
diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml
index 15e2b6df77f60..8d01a5d66bdeb 100644
--- a/gradle/verification-metadata.xml
+++ b/gradle/verification-metadata.xml
@@ -2951,129 +2951,129 @@
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
diff --git a/server/src/test/java/org/elasticsearch/search/query/QueryPhaseTests.java b/server/src/test/java/org/elasticsearch/search/query/QueryPhaseTests.java
index 1f74668158e0e..0d7f16211aa51 100644
--- a/server/src/test/java/org/elasticsearch/search/query/QueryPhaseTests.java
+++ b/server/src/test/java/org/elasticsearch/search/query/QueryPhaseTests.java
@@ -55,6 +55,7 @@
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.search.TotalHits;
+import org.apache.lucene.search.TotalHits.Relation;
import org.apache.lucene.search.Weight;
import org.apache.lucene.search.join.BitSetProducer;
import org.apache.lucene.search.join.ScoreMode;
@@ -567,12 +568,13 @@ public void testTerminateAfterWithHitsNoHitCountShortcut() throws Exception {
// size is lower than terminate_after
context.setSize(5);
// track_total_hits is lower than terminate_after
- context.trackTotalHitsUpTo(randomIntBetween(1, 6));
+ int trackTotalHits = randomIntBetween(1, 6);
+ context.trackTotalHitsUpTo(trackTotalHits);
QueryPhase.executeQuery(context);
// depending on docs distribution we may or may not be able to honor terminate_after: low scoring hits are skipped via
// setMinCompetitiveScore, which bypasses terminate_after until the next leaf collector is pulled, when that happens.
assertThat(context.queryResult().terminatedEarly(), either(is(true)).or(is(false)));
- assertThat(context.queryResult().topDocs().topDocs.totalHits.value(), equalTo(7L));
+ assertThat(context.queryResult().topDocs().topDocs.totalHits.value(), greaterThanOrEqualTo((long) trackTotalHits));
assertThat(context.queryResult().topDocs().topDocs.totalHits.relation(), equalTo(TotalHits.Relation.GREATER_THAN_OR_EQUAL_TO));
assertThat(context.queryResult().topDocs().topDocs.scoreDocs.length, equalTo(5));
}
@@ -990,7 +992,10 @@ public void testMinScore() throws Exception {
context.trackTotalHitsUpTo(5);
QueryPhase.addCollectorsAndSearch(context);
- assertEquals(10, context.queryResult().topDocs().topDocs.totalHits.value());
+ TotalHits totalHits = context.queryResult().topDocs().topDocs.totalHits;
+ assertThat(totalHits.value(), greaterThanOrEqualTo(5L));
+ var expectedRelation = totalHits.value() == 10 ? Relation.EQUAL_TO : Relation.GREATER_THAN_OR_EQUAL_TO;
+ assertThat(totalHits.relation(), is(expectedRelation));
}
}