-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Finalize how search 'fields' option returns nested data. #63709
Comments
Pinging @elastic/es-search (:Search/Search) |
That's a difficult choice to make. I think I understand the reason behind returning nested documents in a more hierarchical way (one nested field might be missing a value, for example, and the array of values for that nested field doesn't shed any light into which nested document is the one that has the missing value) but at the same time one would argue that the format the nested documents are returned into is inconsistent with the one for the rest of the fields. I'd say we could treat
the result is
In SQL I think we only return nested documents as part of |
With the asks of the Kibana team in Discover Switch from _source to fields when fetching data · Issue #80517 · elastic/kibana · GitHub in mind, I’m currently considering the following options:
Two unrelated decisions:
|
Are we also considering the option suggested in the issue description? I don't think this fits neatly into either option you listed. That option would still load all mapped content (including multi-fields), but make sure that the response captures the nested document structure. |
@jtibshirani are you refering to this? I this came up in a discussion with Kibana we had lately, but the problem we saw with this is that using |
Sorry for the confusion, I'm referring to the first option in the description where we return a response like this:
We separate out each nested document in the response, so the structure is preserved. Each nested section contains the 'fields' output, so multi-fields are included, formatting is applied, etc. There is no duplication of data -- for nested documents we only return this structured format instead of the flattened and combined fields. |
At the moment, the ‘fields’ API handles nested fields the same way it handles non-nested object arrays: it just returns them in a flat list. However, the relationship between nested fields is something we should try to preserve, since this is the main purpose of mapping something as “nested” instead of just using an object. This PR changes this by returning grouped field values that are inside a nested object according to the nested object they initially appear in. Any further object structures inside a nested object are again returned as a flattened list. Fields inside nested fields don’t appear in the flattened response outside of the nested path any more. The grouping of fields inside nested objects is applied recursively if nested mappings are defined inside another nested mapping. Closes elastic#63709
At the moment, the ‘fields’ API handles nested fields the same way it handles non-nested object arrays: it just returns them in a flat list. However, the relationship between nested fields is something we should try to preserve, since this is the main purpose of mapping something as “nested” instead of just using an object. This PR changes this by returning grouped field values that are inside a nested object according to the nested object they initially appear in. Any further object structures inside a nested object are again returned as a flattened list. Fields inside nested fields don’t appear in the flattened response outside of the nested path any more. The grouping of fields inside nested objects is applied recursively if nested mappings are defined inside another nested mapping. Closes #63709
This change adds a paragraph on the different response format for nested fields in the fields API and adds an example snippet. Related to elastic#63709
This change adds a paragraph on the different response format for nested fields in the fields API and adds an example snippet. Related to #63709
This change adds a paragraph on the different response format for nested fields in the fields API and adds an example snippet. Related to #63709
A bit late into this discussion but I would like to add another use case. For clients that are trying to access the value of a field that is a child of a I wonder if it would be possible to change |
I understand the problem but I'm on the fence with this request. I would prefer if the java API would mirror the structure of the REST output in the way if presents retrievable keys etc... |
A very pressing question, how to return the map to be generated according to the old scheme? Due to the transition to from version 7.10 -> 7.12, the generation completely broke, while the options for "disabling the new circuit" are not provided or are missing in the documentation |
I'm sorry to hear this is causing problems on your end. However, this is something we reserve to be able to do on "beta" features like the "fields" option in search (see status warning on the 7.10 documentation page). The decision to finalize the API and remove the "beta" status was made in #71130. |
Currently the 'fields' option has no special handling for
nested
fields -- it just returns them in a flat list (as it does for a non-nested object array):This drops the relationship between nested fields and could be misleading about the search behavior. Instead we could return an object array, where each entry contains the fields for a nested document:
Yet another option would be to not return any nested data when requesting 'fields' for the root doc, to match the behavior for
docvalue_fields
. Nested fields would only be available when using theinner_hits
option. This is simple to implement but feels lacking: our users are familiar with _source filtering, which allows for accessing nested objects at the root level.The text was updated successfully, but these errors were encountered: