Skip to content

Commit

Permalink
Adapt BWC after backporting #78765 (#79350)
Browse files Browse the repository at this point in the history
  • Loading branch information
ywelsch authored Oct 18, 2021
1 parent 8510766 commit 120042b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@

package org.elasticsearch.action.search;

import org.elasticsearch.Version;
import org.elasticsearch.action.IndicesRequest;
import org.elasticsearch.action.OriginalIndices;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
Expand Down Expand Up @@ -149,6 +151,14 @@ public CanMatchNodeRequest(StreamInput in) throws IOException {
source = in.readOptionalWriteable(SearchSourceBuilder::new);
indicesOptions = IndicesOptions.readIndicesOptions(in);
searchType = SearchType.fromId(in.readByte());
if (in.getVersion().before(Version.V_8_0_0)) {
// types no longer relevant so ignore
String[] types = in.readStringArray();
if (types.length > 0) {
throw new IllegalStateException(
"types are no longer supported in search requests but found [" + Arrays.toString(types) + "]");
}
}
scroll = in.readOptionalWriteable(Scroll::new);
requestCache = in.readOptionalBoolean();
allowPartialSearchResults = in.readBoolean();
Expand All @@ -167,6 +177,10 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalWriteable(source);
indicesOptions.writeIndicesOptions(out);
out.writeByte(searchType.id());
if (out.getVersion().before(Version.V_8_0_0)) {
// types not supported so send an empty array to previous versions
out.writeStringArray(Strings.EMPTY_ARRAY);
}
out.writeOptionalWriteable(scroll);
out.writeOptionalBoolean(requestCache);
out.writeBoolean(allowPartialSearchResults);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ public void sendCanMatch(Transport.Connection connection, final ShardSearchReque

public void sendCanMatch(Transport.Connection connection, final CanMatchNodeRequest request, SearchTask task, final
ActionListener<CanMatchNodeResponse> listener) {
if (connection.getVersion().onOrAfter(Version.V_8_0_0) &&
connection.getNode().getVersion().onOrAfter(Version.V_8_0_0)) {
if (connection.getVersion().onOrAfter(Version.V_7_16_0) &&
connection.getNode().getVersion().onOrAfter(Version.V_7_16_0)) {
transportService.sendChildRequest(connection, QUERY_CAN_MATCH_NODE_NAME, request, task,
TransportRequestOptions.EMPTY, new ActionListenerResponseHandler<>(listener, CanMatchNodeResponse::new));
} else {
Expand Down

0 comments on commit 120042b

Please sign in to comment.