-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Pushdown for LIKE (LIST) #129557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
julian-elastic
merged 12 commits into
elastic:main
from
julian-elastic:likeListPushdown_v3
Jun 23, 2025
Merged
Pushdown for LIKE (LIST) #129557
Changes from 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
bd481d7
LikeListPushdown
julian-elastic 3b9b494
Update docs/changelog/129557.yaml
julian-elastic 38b8e54
Address code review comments
julian-elastic baaa658
Merge branch 'main' into likeListPushdown_v3
julian-elastic 60426bc
Merge branch 'main' into likeListPushdown_v3
julian-elastic fcd6ce7
Add printable discription for push down Automata
julian-elastic 367cdd9
Add printable description for push down Automata
julian-elastic 58b9978
[CI] Auto commit changes from spotless
26001d3
Merge branch 'main' into likeListPushdown_v3
julian-elastic 567c5b9
Address code review feedback
julian-elastic 9e8c63b
Add support for RLIKE (LIST)
julian-elastic 83835ad
[CI] Auto commit changes from spotless
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| pr: 129557 | ||
| summary: Pushdown for LIKE (LIST) | ||
| area: ES|QL | ||
| type: enhancement | ||
| issues: [] |
102 changes: 102 additions & 0 deletions
102
server/src/main/java/org/elasticsearch/index/query/AutomatonQueryBuilder.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the "Elastic License | ||
| * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| package org.elasticsearch.index.query; | ||
|
|
||
| import org.apache.lucene.index.Term; | ||
| import org.apache.lucene.search.AutomatonQuery; | ||
| import org.apache.lucene.search.Query; | ||
| import org.apache.lucene.util.automaton.Automaton; | ||
| import org.elasticsearch.TransportVersion; | ||
| import org.elasticsearch.common.Strings; | ||
| import org.elasticsearch.common.io.stream.StreamOutput; | ||
| import org.elasticsearch.xcontent.XContentBuilder; | ||
|
|
||
| import java.io.IOException; | ||
| import java.io.UnsupportedEncodingException; | ||
| import java.util.Objects; | ||
|
|
||
| /** | ||
| * Implements an Automaton query, which matches documents based on a Lucene Automaton. | ||
| * It does not support serialization or XContent representation, | ||
| */ | ||
| public class AutomatonQueryBuilder extends AbstractQueryBuilder<AutomatonQueryBuilder> implements MultiTermQueryBuilder { | ||
| private final String fieldName; | ||
| private final Automaton automaton; | ||
| private final String description; | ||
|
|
||
| public AutomatonQueryBuilder(String fieldName, Automaton automaton, String description) { | ||
| this.description = description; | ||
| if (Strings.isEmpty(fieldName)) { | ||
| throw new IllegalArgumentException("field name is null or empty"); | ||
| } | ||
| if (automaton == null) { | ||
| throw new IllegalArgumentException("automaton cannot be null"); | ||
| } | ||
| this.fieldName = fieldName; | ||
| this.automaton = automaton; | ||
| } | ||
|
|
||
| @Override | ||
| public String fieldName() { | ||
| return fieldName; | ||
| } | ||
|
|
||
| @Override | ||
| public String getWriteableName() { | ||
| throw new UnsupportedOperationException("AutomatonQueryBuilder does not support getWriteableName"); | ||
| } | ||
|
|
||
| @Override | ||
| protected void doWriteTo(StreamOutput out) throws IOException { | ||
| throw new UnsupportedEncodingException("AutomatonQueryBuilder does not support doWriteTo"); | ||
| } | ||
|
|
||
| @Override | ||
| protected void doXContent(XContentBuilder builder, Params params) throws IOException { | ||
| throw new UnsupportedEncodingException("AutomatonQueryBuilder does not support doXContent"); | ||
| } | ||
|
|
||
| @Override | ||
| protected Query doToQuery(SearchExecutionContext context) throws IOException { | ||
| return new AutomatonQueryWithDescription(new Term(fieldName), automaton, description); | ||
| } | ||
|
|
||
| @Override | ||
| protected int doHashCode() { | ||
| return Objects.hash(fieldName, automaton); | ||
| } | ||
|
|
||
| @Override | ||
| protected boolean doEquals(AutomatonQueryBuilder other) { | ||
| return Objects.equals(fieldName, other.fieldName) && Objects.equals(automaton, other.automaton); | ||
| } | ||
|
|
||
| @Override | ||
| public TransportVersion getMinimalSupportedVersion() { | ||
| throw new UnsupportedOperationException("AutomatonQueryBuilder does not support getMinimalSupportedVersion"); | ||
| } | ||
|
|
||
| static class AutomatonQueryWithDescription extends AutomatonQuery { | ||
| private final String description; | ||
|
|
||
| AutomatonQueryWithDescription(Term term, Automaton automaton, String description) { | ||
| super(term, automaton); | ||
| this.description = description; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString(String field) { | ||
| if (description.isEmpty()) { | ||
| return super.toString(field); | ||
| } | ||
| return description; | ||
julian-elastic marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| } | ||
64 changes: 64 additions & 0 deletions
64
...l-core/src/main/java/org/elasticsearch/xpack/esql/core/querydsl/query/AutomatonQuery.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
| package org.elasticsearch.xpack.esql.core.querydsl.query; | ||
|
|
||
| import org.apache.lucene.util.automaton.Automaton; | ||
| import org.elasticsearch.index.query.AutomatonQueryBuilder; | ||
| import org.elasticsearch.index.query.QueryBuilder; | ||
| import org.elasticsearch.xpack.esql.core.tree.Source; | ||
|
|
||
| import java.util.Objects; | ||
|
|
||
| /** | ||
| * Query that matches documents based on a Lucene Automaton. | ||
| */ | ||
| public class AutomatonQuery extends Query { | ||
|
|
||
| private final String field; | ||
| private final Automaton automaton; | ||
| private final String automatonDescription; | ||
|
|
||
| public AutomatonQuery(Source source, String field, Automaton automaton, String automatonDescription) { | ||
| super(source); | ||
| this.field = field; | ||
| this.automaton = automaton; | ||
| this.automatonDescription = automatonDescription; | ||
| } | ||
|
|
||
| public String field() { | ||
| return field; | ||
| } | ||
|
|
||
| @Override | ||
| protected QueryBuilder asBuilder() { | ||
| return new AutomatonQueryBuilder(field, automaton, automatonDescription); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(field, automaton); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object obj) { | ||
| if (this == obj) { | ||
| return true; | ||
| } | ||
|
|
||
| if (obj == null || getClass() != obj.getClass()) { | ||
| return false; | ||
| } | ||
|
|
||
| AutomatonQuery other = (AutomatonQuery) obj; | ||
| return Objects.equals(field, other.field) && Objects.equals(automaton, other.automaton); | ||
| } | ||
|
|
||
| @Override | ||
| protected String innerToString() { | ||
| return "AutomatonQuery{" + "field='" + field + '\'' + '}'; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.