Skip to content

Commit cbd88cd

Browse files
[main]Prepare Index Like fix for backport to 9.1 and 8.19 (elastic#130947)
Add transport versions to prepare for backport of elastic#130849 to 9.1 and 8.19
1 parent da218c8 commit cbd88cd

File tree

5 files changed

+28
-4
lines changed

5 files changed

+28
-4
lines changed

docs/changelog/130947.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 130947
2+
summary: "[main]Prepare Index Like fix for backport to 9.1 and 8.19"
3+
area: ES|QL
4+
type: bug
5+
issues: []

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ static TransportVersion def(int id) {
211211
public static final TransportVersion ESQL_DOCUMENTS_FOUND_AND_VALUES_LOADED_8_19 = def(8_841_0_61);
212212
public static final TransportVersion ESQL_PROFILE_INCLUDE_PLAN_8_19 = def(8_841_0_62);
213213
public static final TransportVersion ESQL_SPLIT_ON_BIG_VALUES_8_19 = def(8_841_0_63);
214+
public static final TransportVersion ESQL_FIXED_INDEX_LIKE_8_19 = def(8_841_0_64);
214215
public static final TransportVersion V_9_0_0 = def(9_000_0_09);
215216
public static final TransportVersion INITIAL_ELASTICSEARCH_9_0_1 = def(9_000_0_10);
216217
public static final TransportVersion INITIAL_ELASTICSEARCH_9_0_2 = def(9_000_0_11);
@@ -328,6 +329,7 @@ static TransportVersion def(int id) {
328329
public static final TransportVersion ESQL_PROFILE_INCLUDE_PLAN = def(9_111_0_00);
329330
public static final TransportVersion MAPPINGS_IN_DATA_STREAMS = def(9_112_0_00);
330331
public static final TransportVersion ESQL_SPLIT_ON_BIG_VALUES_9_1 = def(9_112_0_01);
332+
public static final TransportVersion ESQL_FIXED_INDEX_LIKE_9_1 = def(9_112_0_02);
331333
// Below is the first version in 9.2 and NOT in 9.1.
332334
public static final TransportVersion PROJECT_STATE_REGISTRY_RECORDS_DELETIONS = def(9_113_0_00);
333335
public static final TransportVersion ESQL_SERIALIZE_TIMESERIES_FIELD_TYPE = def(9_114_0_00);

server/src/main/java/org/elasticsearch/index/query/WildcardQueryBuilder.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public WildcardQueryBuilder(StreamInput in) throws IOException {
104104
value = in.readString();
105105
rewrite = in.readOptionalString();
106106
caseInsensitive = in.readBoolean();
107-
if (in.getTransportVersion().onOrAfter(TransportVersions.ESQL_FIXED_INDEX_LIKE)) {
107+
if (expressionTransportSupported(in.getTransportVersion())) {
108108
forceStringMatch = in.readBoolean();
109109
} else {
110110
forceStringMatch = false;
@@ -117,11 +117,20 @@ protected void doWriteTo(StreamOutput out) throws IOException {
117117
out.writeString(value);
118118
out.writeOptionalString(rewrite);
119119
out.writeBoolean(caseInsensitive);
120-
if (out.getTransportVersion().onOrAfter(TransportVersions.ESQL_FIXED_INDEX_LIKE)) {
120+
if (expressionTransportSupported(out.getTransportVersion())) {
121121
out.writeBoolean(forceStringMatch);
122122
}
123123
}
124124

125+
/**
126+
* Returns true if the Transport version is compatible with ESQL_FIXED_INDEX_LIKE
127+
*/
128+
public static boolean expressionTransportSupported(TransportVersion version) {
129+
return version.onOrAfter(TransportVersions.ESQL_FIXED_INDEX_LIKE)
130+
|| version.isPatchFrom(TransportVersions.ESQL_FIXED_INDEX_LIKE_8_19)
131+
|| version.isPatchFrom(TransportVersions.ESQL_FIXED_INDEX_LIKE_9_1);
132+
}
133+
125134
@Override
126135
public String fieldName() {
127136
return fieldName;

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/regex/WildcardLikeList.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import org.apache.lucene.util.automaton.Automaton;
1212
import org.apache.lucene.util.automaton.CharacterRunAutomaton;
1313
import org.elasticsearch.TransportVersion;
14-
import org.elasticsearch.TransportVersions;
1514
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
1615
import org.elasticsearch.common.io.stream.StreamInput;
1716
import org.elasticsearch.common.io.stream.StreamOutput;
@@ -35,6 +34,8 @@
3534
import java.util.function.Supplier;
3635
import java.util.stream.Collectors;
3736

37+
import static org.elasticsearch.index.query.WildcardQueryBuilder.expressionTransportSupported;
38+
3839
public class WildcardLikeList extends RegexMatch<WildcardPatternList> {
3940
public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(
4041
Expression.class,
@@ -145,7 +146,7 @@ public Query asQuery(LucenePushdownPredicates pushdownPredicates, TranslatorHand
145146
}
146147

147148
private boolean supportsPushdown(TransportVersion version) {
148-
return version == null || version.onOrAfter(TransportVersions.ESQL_FIXED_INDEX_LIKE);
149+
return version == null || expressionTransportSupported(version);
149150
}
150151

151152
@Override

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/io/stream/PlanStreamWrapperQueryBuilder.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
import java.io.IOException;
2222

23+
import static org.elasticsearch.index.query.WildcardQueryBuilder.expressionTransportSupported;
24+
2325
/**
2426
* A {@link QueryBuilder} that wraps another {@linkplain QueryBuilder}
2527
* so it read with a {@link PlanStreamInput}.
@@ -56,6 +58,11 @@ public TransportVersion getMinimalSupportedVersion() {
5658
return TransportVersions.ESQL_FIXED_INDEX_LIKE;
5759
}
5860

61+
@Override
62+
public boolean supportsVersion(TransportVersion version) {
63+
return expressionTransportSupported(version);
64+
}
65+
5966
@Override
6067
public Query toQuery(SearchExecutionContext context) throws IOException {
6168
return next.toQuery(context);

0 commit comments

Comments
 (0)