-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
SQL: improve the nested documents handling #33079
Labels
:Analytics/SQL
SQL querying
>enhancement
Team:Analytics
Meta label for analytical engine team (ESQL/Aggs/Geo)
Comments
Pinging @elastic/es-search-aggs |
Relevant discussion - #33204 (comment). |
Hi, I'm just pinging to see if there's been any progress on this issue (or #33204) ? Thanks. |
Hi @paulcarey, |
elasticsearchmachine
added
the
Team:Analytics
Meta label for analytical engine team (ESQL/Aggs/Geo)
label
Jan 17, 2024
Pinging @elastic/es-analytical-engine (Team:Analytics) |
superceded by ES|QL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
:Analytics/SQL
SQL querying
>enhancement
Team:Analytics
Meta label for analytical engine team (ESQL/Aggs/Geo)
At the moment, when a query needs to touch nested documents, it is creating a
nested
query for eachwhere
clause. Something like the following (simplified) for theselect groupName from my_index where user.first = 'Alice' and user.last = 'Smith'
query (whereuser
is anested
field):Which is a perfectly valid query for a
nested
documents scenario: get all documents where at least one of the nested values in it (user.first
in this case) isAlice
and also another nested value (not necessarily the first one) in it (user.last
in this case) isSmith
.But there is also the scenario where one would want to get the same nested document to have those values, meaning an
user
namedAlice Smith
.In this second scenario, the query that needs to be generated is different:
Source: https://discuss.elastic.co/t/sql-queries-against-nested-datatypes-may-be-mis-translated/145180
To summarize this issue, I believe that the user creating the SQL query needs to be the decider between one functionality and the other. And there are two main (simplified) functionalities when it comes to
nested
documents:WHERE
, ES SQL builds a separatenested
query and combines them in abool
nested
query should surround abool
query containing theWHERE
conditions queriesFrom what I've seen in the past, I believe the most common functionality is the second one, where one is interested in the conditions applied to a
nested
document to be fulfilled at the same time. Also, I don't think ES SQL can decide by itself what kind of query to build, since this is a matter of functionality choice (something that only the user can decide upon).The text was updated successfully, but these errors were encountered: