Skip to content

Commit 9e87a37

Browse files
refactor and bugfix
1 parent f22d7e7 commit 9e87a37

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
/**
1717
* Query that matches documents based on a Lucene Automaton.
1818
*/
19-
public class AutomatonQuery extends Query {
19+
public class EsqlAutomatonQuery extends Query {
2020

2121
private final String field;
2222
private final Automaton automaton;
2323
private final String automatonDescription;
2424

25-
public AutomatonQuery(Source source, String field, Automaton automaton, String automatonDescription) {
25+
public EsqlAutomatonQuery(Source source, String field, Automaton automaton, String automatonDescription) {
2626
super(source);
2727
this.field = field;
2828
this.automaton = automaton;
@@ -53,8 +53,10 @@ public boolean equals(Object obj) {
5353
return false;
5454
}
5555

56-
AutomatonQuery other = (AutomatonQuery) obj;
57-
return Objects.equals(field, other.field) && Objects.equals(automaton, other.automaton) && Objects.equals(automatonDescription, other.automatonDescription);
56+
EsqlAutomatonQuery other = (EsqlAutomatonQuery) obj;
57+
return Objects.equals(field, other.field)
58+
&& Objects.equals(automaton, other.automaton)
59+
&& Objects.equals(automatonDescription, other.automatonDescription);
5860
}
5961

6062
@Override

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: 2 additions & 2 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.WildcardPattern;
1616
import org.elasticsearch.xpack.esql.core.expression.predicate.regex.WildcardPatternList;
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.querydsl.query.WildcardQuery;
2020
import org.elasticsearch.xpack.esql.core.tree.NodeInfo;
@@ -112,7 +112,7 @@ public Query asQuery(LucenePushdownPredicates pushdownPredicates, TranslatorHand
112112
* Throws an {@link IllegalArgumentException} if the pattern list contains more than one pattern.
113113
*/
114114
private Query translateField(String targetFieldName) {
115-
return new AutomatonQuery(source(), targetFieldName, pattern().createAutomaton(caseInsensitive()), getAutomatonDescription());
115+
return new EsqlAutomatonQuery(source(), targetFieldName, pattern().createAutomaton(caseInsensitive()), getAutomatonDescription());
116116
}
117117

118118
private String getAutomatonDescription() {

0 commit comments

Comments
 (0)