-
Notifications
You must be signed in to change notification settings - Fork 25.2k
QL: Optimize Like/Rlike all #62682
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
QL: Optimize Like/Rlike all #62682
Conversation
Replace common Like and RLike queries that match all characters with IsNotNull (exists) queries Fix elastic#62585
Pinging @elastic/es-ql (:Query Languages/EQL) |
Pinging @elastic/es-ql (:Query Languages/SQL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a comment about the Like/LikePattern.
...ugin/ql/src/main/java/org/elasticsearch/xpack/ql/expression/predicate/regex/LikePattern.java
Outdated
Show resolved
Hide resolved
I've added more tests to check the query translation and it turns out
It's worth revisiting some of the translations since this might not be singular case. |
@Override | ||
public boolean matchesAll() { | ||
for (int i = 0 ; i < pattern.length(); i++) { | ||
if (pattern.charAt(i) != '%') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that now the "problem" is reversed since the ReplaceWildcards takes place before this rule, but the test seems to work: https://github.com/elastic/elasticsearch/pull/62682/files#diff-6dd3fd1d0809ee5978cdccbc6bb7d7e1R17 ? In any case I think we should have a comment mentioning the order of the rules are applied and the choice of % or * in this rule.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LikePattern
has several styles. In its constructor it accepts the %
and _
characters instead of *
and ?
. The conversion is done internally and accessible.
The check above works on the raw pattern - I'll follow-up with a comment.
Relates to #62760 |
@elasticmachine update branch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, nice approach with the new checks.
Replace common Like and RLike queries that match all characters with
IsNotNull (exists) queries
Fix #62585