#47046 Fix serialization version check after backport

This commit is contained in:
jimczi 2019-09-26 09:56:24 +02:00
parent 04972baffa
commit 97d977f381
1 changed files with 24 additions and 6 deletions

View File

@ -19,6 +19,7 @@
package org.elasticsearch.search.internal; package org.elasticsearch.search.internal;
import org.elasticsearch.Version;
import org.elasticsearch.action.IndicesRequest; import org.elasticsearch.action.IndicesRequest;
import org.elasticsearch.action.OriginalIndices; import org.elasticsearch.action.OriginalIndices;
import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchRequest;
@ -160,9 +161,20 @@ public class ShardSearchRequest extends TransportRequest implements IndicesReque
nowInMillis = in.readVLong(); nowInMillis = in.readVLong();
requestCache = in.readOptionalBoolean(); requestCache = in.readOptionalBoolean();
clusterAlias = in.readOptionalString(); clusterAlias = in.readOptionalString();
allowPartialSearchResults = in.readBoolean(); if (in.getVersion().onOrAfter(Version.V_7_0_0)) {
indexRoutings = in.readStringArray(); allowPartialSearchResults = in.readBoolean();
preference = in.readOptionalString(); } else if (in.getVersion().onOrAfter(Version.V_6_3_0)) {
allowPartialSearchResults = in.readOptionalBoolean();
} else {
allowPartialSearchResults = false;
}
if (in.getVersion().onOrAfter(Version.V_6_4_0)) {
indexRoutings = in.readStringArray();
preference = in.readOptionalString();
} else {
indexRoutings = Strings.EMPTY_ARRAY;
preference = null;
}
originalIndices = OriginalIndices.readOriginalIndices(in); originalIndices = OriginalIndices.readOriginalIndices(in);
} }
@ -189,10 +201,16 @@ public class ShardSearchRequest extends TransportRequest implements IndicesReque
} }
out.writeOptionalBoolean(requestCache); out.writeOptionalBoolean(requestCache);
out.writeOptionalString(clusterAlias); out.writeOptionalString(clusterAlias);
out.writeBoolean(allowPartialSearchResults); if (out.getVersion().onOrAfter(Version.V_7_0_0)) {
out.writeBoolean(allowPartialSearchResults);
} else if (out.getVersion().onOrAfter(Version.V_6_3_0)) {
out.writeOptionalBoolean(allowPartialSearchResults);
}
if (asKey == false) { if (asKey == false) {
out.writeStringArray(indexRoutings); if (out.getVersion().onOrAfter(Version.V_6_4_0)) {
out.writeOptionalString(preference); out.writeStringArray(indexRoutings);
out.writeOptionalString(preference);
}
} }
} }