-
Notifications
You must be signed in to change notification settings - Fork 25.6k
KQL: Support boolean operators in field queries #133737
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) |
Hi @afoucret, I've created a changelog YAML for you. |
…kql-fix-132366
d7c272f
to
636ad82
Compare
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, left some minor comments, will leave the grammar review to others 👍
x-pack/plugin/kql/src/main/java/org/elasticsearch/xpack/kql/parser/KqlAstBuilder.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/kql/src/main/java/org/elasticsearch/xpack/kql/parser/KqlAstBuilder.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/kql/src/test/java/org/elasticsearch/xpack/kql/parser/KqlParserTests.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/kql/src/test/java/org/elasticsearch/xpack/kql/parser/KqlParserTests.java
Outdated
Show resolved
Hide resolved
{ | ||
"query": { "kql": { "query": "text_field:(bar OR baz)" } } | ||
} | ||
- match: { hits.total: 2 } |
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.
Match hit IDs here?
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.
Not really needed cause the index contains only two docs, so just checking the number of results is enough to check that all docs are returned.
x-pack/plugin/kql/src/yamlRestTest/resources/rest-api-spec/test/kql/10_kql_basic_query.yml
Show resolved
Hide resolved
x-pack/plugin/kql/src/yamlRestTest/resources/rest-api-spec/test/kql/10_kql_basic_query.yml
Outdated
Show resolved
Hide resolved
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 👍
…kql-fix-132366
…kql-fix-132366
💔 Backport failed
You can use sqren/backport to manually backport by running |
(cherry picked from commit 36a00d1)
💔 Some backports could not be created
Manual backportTo create the backport manually run:
Questions ?Please refer to the Backport tool documentation |
(cherry picked from commit 36a00d1)
Fixes #132366
Description
This pull request introduces support for boolean operators (
AND
,OR
,NOT
) within KQL field queries.Previously, it was not possible to combine multiple conditions for a single field using boolean logic. For instance, a query like
response:(200 AND ok)
would not be parsed correctly.Changes summary:
Example:
A query like
response:((200 AND "OK") OR 404)
is now supported and will be translated into the appropriate boolean query.