-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Implement string parsing for the KQL parser. #115662
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
Conversation
Pinging @elastic/es-search-relevance (Team:Search Relevance) |
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 thanks Aurelien ;)
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! 💯
x-pack/plugin/kql/src/main/java/org/elasticsearch/xpack/kql/parser/ParserUtils.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Carlos Delgado <6339205+carlosdelest@users.noreply.github.com>
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.
Nice work!
x-pack/plugin/kql/src/main/java/org/elasticsearch/xpack/kql/parser/ParserUtils.java
Outdated
Show resolved
Hide resolved
if (preserveWildcards) { | ||
StringBuilder escapedQuery = new StringBuilder(queryText.length()); | ||
StringBuilder subpart = new StringBuilder(queryText.length()); | ||
for (int i = 0; i < queryText.length(); 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 you could write this a little more readable, something like:
for (char currentChar : queryText.toCharArray()) {
if (currentChar == '*') {
escapedQuery.append(QueryParser.escape(subpart.toString())).append(currentChar);
subpart.setLength(0);
} else {
subpart.append(currentChar);
}
}
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.
Done. Thank you!
StringBuilder subpart = new StringBuilder(queryText.length()); | ||
for (int i = 0; i < queryText.length(); i++) { | ||
char currentChar = queryText.charAt(i); | ||
if (currentChar == '*') { |
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.
Nitpick - would be nice to use a constant for WILDCARD_CHAR
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.
Done. Thank you!
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.
Nice tests!
Co-authored-by: Kathleen DeRusso <kathleen.derusso@elastic.co>
x-pack/plugin/kql/src/main/java/org/elasticsearch/xpack/kql/parser/ParserUtils.java
Outdated
Show resolved
Hide resolved
💚 Backport successful
|
This PR implement text extraction for the KQL parser quoted and unquoted strings.