Skip to content

Commit 788cd26

Browse files
Fix missing BwC in QuerySearchResult (#126636)
Forgot to update for 8.19.x changes after backporting. closes #126633 closes #126632
1 parent 1324f82 commit 788cd26

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

muted-tests.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -423,12 +423,6 @@ tests:
423423
- class: org.elasticsearch.index.shard.IndexShardTests
424424
method: testReentrantEngineReadLockAcquisitionInRefreshListener
425425
issue: https://github.com/elastic/elasticsearch/issues/126628
426-
- class: org.elasticsearch.upgrades.SearchStatesIT
427-
method: testBWCSearchStates
428-
issue: https://github.com/elastic/elasticsearch/issues/126632
429-
- class: org.elasticsearch.upgrades.SearchStatesIT
430-
method: testCanMatch
431-
issue: https://github.com/elastic/elasticsearch/issues/126633
432426
- class: org.elasticsearch.xpack.esql.action.EsqlActionIT
433427
method: testQueryOnEmptyDataIndex
434428
issue: https://github.com/elastic/elasticsearch/issues/126580

server/src/main/java/org/elasticsearch/TransportVersions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ static TransportVersion def(int id) {
158158
public static final TransportVersion RERANK_COMMON_OPTIONS_ADDED_8_19 = def(8_841_0_15);
159159
public static final TransportVersion REMOTE_EXCEPTION_8_19 = def(8_841_0_16);
160160
public static final TransportVersion AMAZON_BEDROCK_TASK_SETTINGS_8_19 = def(8_841_0_17);
161+
public static final TransportVersion BATCHED_QUERY_PHASE_VERSION_BACKPORT_8_X = def(8_841_0_19);
161162
public static final TransportVersion INITIAL_ELASTICSEARCH_9_0 = def(9_000_0_00);
162163
public static final TransportVersion REMOVE_SNAPSHOT_FAILURES_90 = def(9_000_0_01);
163164
public static final TransportVersion TRANSPORT_STATS_HANDLING_TIME_REQUIRED_90 = def(9_000_0_02);

server/src/main/java/org/elasticsearch/search/query/QuerySearchResult.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import org.apache.lucene.search.FieldDoc;
1313
import org.apache.lucene.search.TotalHits;
14+
import org.elasticsearch.TransportVersion;
1415
import org.elasticsearch.TransportVersions;
1516
import org.elasticsearch.common.io.stream.DelayableWriteable;
1617
import org.elasticsearch.common.io.stream.StreamInput;
@@ -92,7 +93,7 @@ public QuerySearchResult(StreamInput in) throws IOException {
9293
public QuerySearchResult(StreamInput in, boolean delayedAggregations) throws IOException {
9394
isNull = in.readBoolean();
9495
if (isNull == false) {
95-
ShardSearchContextId id = in.getTransportVersion().onOrAfter(TransportVersions.BATCHED_QUERY_PHASE_VERSION)
96+
ShardSearchContextId id = versionSupportsBatchedExecution(in.getTransportVersion())
9697
? in.readOptionalWriteable(ShardSearchContextId::new)
9798
: new ShardSearchContextId(in);
9899
readFromWithId(id, in, delayedAggregations);
@@ -410,7 +411,7 @@ private void readFromWithId(ShardSearchContextId id, StreamInput in, boolean del
410411
sortValueFormats[i] = in.readNamedWriteable(DocValueFormat.class);
411412
}
412413
}
413-
if (in.getTransportVersion().onOrAfter(TransportVersions.BATCHED_QUERY_PHASE_VERSION)) {
414+
if (versionSupportsBatchedExecution(in.getTransportVersion())) {
414415
if (in.readBoolean()) {
415416
setTopDocs(readTopDocs(in));
416417
}
@@ -440,7 +441,7 @@ private void readFromWithId(ShardSearchContextId id, StreamInput in, boolean del
440441
setRescoreDocIds(new RescoreDocIds(in));
441442
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_8_0)) {
442443
rankShardResult = in.readOptionalNamedWriteable(RankShardResult.class);
443-
if (in.getTransportVersion().onOrAfter(TransportVersions.BATCHED_QUERY_PHASE_VERSION)) {
444+
if (versionSupportsBatchedExecution(in.getTransportVersion())) {
444445
reduced = in.readBoolean();
445446
}
446447
}
@@ -461,7 +462,7 @@ public void writeTo(StreamOutput out) throws IOException {
461462
}
462463
out.writeBoolean(isNull);
463464
if (isNull == false) {
464-
if (out.getTransportVersion().onOrAfter(TransportVersions.BATCHED_QUERY_PHASE_VERSION)) {
465+
if (versionSupportsBatchedExecution(out.getTransportVersion())) {
465466
out.writeOptionalWriteable(contextId);
466467
} else {
467468
contextId.writeTo(out);
@@ -481,7 +482,7 @@ public void writeToNoId(StreamOutput out) throws IOException {
481482
out.writeNamedWriteable(sortValueFormats[i]);
482483
}
483484
}
484-
if (out.getTransportVersion().onOrAfter(TransportVersions.BATCHED_QUERY_PHASE_VERSION)) {
485+
if (versionSupportsBatchedExecution(out.getTransportVersion())) {
485486
if (topDocsAndMaxScore != null) {
486487
out.writeBoolean(true);
487488
writeTopDocs(out, topDocsAndMaxScore);
@@ -511,7 +512,7 @@ public void writeToNoId(StreamOutput out) throws IOException {
511512
} else if (rankShardResult != null) {
512513
throw new IllegalArgumentException("cannot serialize [rank] to version [" + out.getTransportVersion().toReleaseVersion() + "]");
513514
}
514-
if (out.getTransportVersion().onOrAfter(TransportVersions.BATCHED_QUERY_PHASE_VERSION)) {
515+
if (versionSupportsBatchedExecution(out.getTransportVersion())) {
515516
out.writeBoolean(reduced);
516517
}
517518
}
@@ -561,4 +562,9 @@ public boolean hasReferences() {
561562
}
562563
return super.hasReferences();
563564
}
565+
566+
private static boolean versionSupportsBatchedExecution(TransportVersion transportVersion) {
567+
return transportVersion.onOrAfter(TransportVersions.BATCHED_QUERY_PHASE_VERSION)
568+
|| transportVersion.isPatchFrom(TransportVersions.BATCHED_QUERY_PHASE_VERSION_BACKPORT_8_X);
569+
}
564570
}

0 commit comments

Comments
 (0)