-
Notifications
You must be signed in to change notification settings - Fork 24.6k
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
ES|QL Search: allow WHERE with text predicates #110132
Conversation
var actualLuceneQuery = as(fieldExtract.child(), EsQueryExec.class).query(); | ||
|
||
var expectedLuceneQuery = new BoolQueryBuilder().filter( | ||
new BoolQueryBuilder().must(new MatchQueryBuilder("first_name", "Meg")).must(new MatchQueryBuilder("last_name", "Ryan")) |
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.
this is an interesting behaviour that we can follow up on separately.
I would expect that we just have a bool query with two filter clauses:
var expectedLuceneQuery = new BoolQueryBuilder().filter(new MatchQueryBuilder("first_name", "Meg")).filter(new MatchQueryBuilder("last_name", "Ryan"))
instead we are using must
clauses which comes from how the PushFiltersToSource
forms the query, specifically here:
Line 222 in 90047f9
Query queryDSL = TRANSLATOR_HANDLER.asQuery(Predicates.combineAnd(pushable)); |
We can see that this behaviour happens with FROM
too, take this test query:
Lines 236 to 240 in dabd9b6
var plan = plannerOptimizer.plan(""" | |
from test | |
| where salary > 1000 | |
| stats c = count(salary) | |
""", IS_SV_STATS); |
the filters are pushed as must
clauses:
Line 255 in dabd9b6
var expected = QueryBuilders.boolQuery().must(range).must(exists); |
I think maybe they should be pushed as filter
instead since must
clauses add to the score which for filters we don't care about?
EDIT: maybe this is okay since we wrap everything in a constant score anyway for the FROM
command and Lucene optimizations should kick in?
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.
That's a good question. It works ok, by I also suspect that filter
would be more appropriate here.
Pinging @elastic/es-search (Team:Search) |
@elasticsearchmachine test this please |
@elasticmachine update branch |
@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
When
WHERE
is used in the search context of theSEARCH
command it can now receive the expressions usingMATCH
.This will apply a boolean query with a filter clause - the returned results will have scores equal to zero, since no ranking is happening.
The grammar has been simplified, so for the moment
WHERE
andRANK
allow the same type of expressions when used in theSEARCH
context.