diff --git a/server/src/main/java/org/elasticsearch/TransportVersions.java b/server/src/main/java/org/elasticsearch/TransportVersions.java index d6f405959f2b7..b1f8eec376d38 100644 --- a/server/src/main/java/org/elasticsearch/TransportVersions.java +++ b/server/src/main/java/org/elasticsearch/TransportVersions.java @@ -189,7 +189,7 @@ static TransportVersion def(int id) { public static final TransportVersion DATA_STREAM_OPTIONS_API_REMOVE_INCLUDE_DEFAULTS_8_19 = def(8_841_0_41); public static final TransportVersion JOIN_ON_ALIASES_8_19 = def(8_841_0_42); public static final TransportVersion ILM_ADD_SKIP_SETTING_8_19 = def(8_841_0_43); - public static final TransportVersion ML_INFERENCE_MISTRAL_CHAT_COMPLETION_ADDED_8_19 = def(8_841_0_44); + public static final TransportVersion ESQL_REGEX_MATCH_WITH_CASE_INSENSITIVITY_8_19 = def(8_841_0_44); public static final TransportVersion V_9_0_0 = def(9_000_0_09); public static final TransportVersion INITIAL_ELASTICSEARCH_9_0_1 = def(9_000_0_10); public static final TransportVersion INITIAL_ELASTICSEARCH_9_0_2 = def(9_000_0_11); diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/regex/RegexMatch.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/regex/RegexMatch.java index eb5e06a686320..140bbd697ce9e 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/regex/RegexMatch.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/regex/RegexMatch.java @@ -72,22 +72,25 @@ public String nodeString() { } void serializeCaseInsensitivity(StreamOutput out) throws IOException { - if (out.getTransportVersion().before(TransportVersions.ESQL_REGEX_MATCH_WITH_CASE_INSENSITIVITY)) { - if (caseInsensitive()) { - // The plan has been optimized to run a case-insensitive match, which the remote peer cannot be notified of. Simply avoiding - // the serialization of the boolean would result in wrong results. - throw new EsqlIllegalArgumentException( - name() + " with case insensitivity is not supported in peer node's version [{}]. Upgrade to version [{}] or newer.", - out.getTransportVersion(), - TransportVersions.ESQL_REGEX_MATCH_WITH_CASE_INSENSITIVITY - ); - } // else: write nothing, the remote peer can execute the case-sensitive query - } else { + var transportVersion = out.getTransportVersion(); + if (transportVersion.onOrAfter(TransportVersions.ESQL_REGEX_MATCH_WITH_CASE_INSENSITIVITY) + || transportVersion.isPatchFrom(TransportVersions.ESQL_REGEX_MATCH_WITH_CASE_INSENSITIVITY_8_19)) { out.writeBoolean(caseInsensitive()); - } + } else if (caseInsensitive()) { + // The plan has been optimized to run a case-insensitive match, which the remote peer cannot be notified of. Simply avoiding + // the serialization of the boolean would result in wrong results. + throw new EsqlIllegalArgumentException( + name() + " with case insensitivity is not supported in peer node's version [{}]. Upgrade to version [{}, {}] or newer.", + transportVersion, + TransportVersions.ESQL_REGEX_MATCH_WITH_CASE_INSENSITIVITY_8_19, + TransportVersions.ESQL_REGEX_MATCH_WITH_CASE_INSENSITIVITY + ); + } // else: write nothing, the remote peer can execute the case-sensitive query } static boolean deserializeCaseInsensitivity(StreamInput in) throws IOException { - return in.getTransportVersion().onOrAfter(TransportVersions.ESQL_REGEX_MATCH_WITH_CASE_INSENSITIVITY) && in.readBoolean(); + var transportVersion = in.getTransportVersion(); + return (transportVersion.onOrAfter(TransportVersions.ESQL_REGEX_MATCH_WITH_CASE_INSENSITIVITY) + || transportVersion.isPatchFrom(TransportVersions.ESQL_REGEX_MATCH_WITH_CASE_INSENSITIVITY_8_19)) && in.readBoolean(); } }