Skip to content

Commit 0866016

Browse files
refactor and bugfix
1 parent f2d56d7 commit 0866016

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import org.elasticsearch.xpack.esql.core.expression.FieldAttribute;
1515
import org.elasticsearch.xpack.esql.core.expression.predicate.regex.RLikePattern;
1616
import org.elasticsearch.xpack.esql.core.expression.predicate.regex.RLikePatternList;
17-
import org.elasticsearch.xpack.esql.core.querydsl.query.AutomatonQuery;
17+
import org.elasticsearch.xpack.esql.core.querydsl.query.EsqlAutomatonQuery;
1818
import org.elasticsearch.xpack.esql.core.querydsl.query.Query;
1919
import org.elasticsearch.xpack.esql.core.tree.NodeInfo;
2020
import org.elasticsearch.xpack.esql.core.tree.Source;
@@ -85,19 +85,21 @@ public Translatable translatable(LucenePushdownPredicates pushdownPredicates) {
8585
return pushdownPredicates.isPushableAttribute(field()) ? Translatable.YES : Translatable.NO;
8686
}
8787

88+
8889
/**
8990
* Returns a {@link Query} that matches the field against the provided patterns.
9091
* For now, we only support a single pattern in the list for pushdown.
9192
*/
9293
@Override
9394
public Query asQuery(LucenePushdownPredicates pushdownPredicates, TranslatorHandler handler) {
95+
//throw new RuntimeException("As query called");
9496
var field = field();
9597
LucenePushdownPredicates.checkIsPushableAttribute(field);
9698
return translateField(handler.nameOf(field instanceof FieldAttribute fa ? fa.exactAttribute() : field));
9799
}
98100

99101
private Query translateField(String targetFieldName) {
100-
return new AutomatonQuery(source(), targetFieldName, pattern().createAutomaton(caseInsensitive()), getAutomatonDescription());
102+
return new EsqlAutomatonQuery(source(), targetFieldName, pattern().createAutomaton(caseInsensitive()), getAutomatonDescription());
101103
}
102104

103105
@Override
@@ -108,6 +110,6 @@ protected NodeInfo<? extends Expression> info() {
108110
private String getAutomatonDescription() {
109111
// we use the information used to create the automaton to describe the query here
110112
String patternDesc = pattern().patternList().stream().map(RLikePattern::pattern).collect(Collectors.joining("\", \""));
111-
return "LIKE(\"" + patternDesc + "\"), caseInsensitive=" + caseInsensitive();
113+
return "RLIKE(\"" + patternDesc + "\"), caseInsensitive=" + caseInsensitive();
112114
}
113115
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ public Query asQuery(LucenePushdownPredicates pushdownPredicates, TranslatorHand
147147

148148
private boolean supportsPushdown(TransportVersion version) {
149149
return version == null || expressionTransportSupported(version);
150+
return new EsqlAutomatonQuery(source(), targetFieldName, pattern().createAutomaton(caseInsensitive()), getAutomatonDescription());
150151
}
151152

152153
@Override

0 commit comments

Comments
 (0)