Skip to content
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

Support fetching flattened subfields #70916

Merged
merged 10 commits into from
Apr 15, 2021

Conversation

cbuescher
Copy link
Member

Currently the fields API fetches the root flattened field and returns it in a
structured way in the response. In addition this change makes it possible to
directly query subfields. However, requesting flattened subfields via wildcard
patterns is not possible.

Closes #70605

Currently the `fields` API fetches the root flattened field and returns it in a
structured way in the response. In addition this change makes it possible to
directly query subfields. However, requesting flattened subfields via wildcard
patterns is not possible.

Closes elastic#70605
@cbuescher cbuescher added >enhancement :Search Foundations/Mapping Index mappings, including merging and defining field types v8.0.0 v7.13.0 labels Mar 26, 2021
@elasticmachine elasticmachine added the Team:Search Meta label for search team label Mar 26, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (Team:Search)

Copy link
Contributor

@romseygeek romseygeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is generally the right way to go - left a couple of comments.

Copy link
Contributor

@jtibshirani jtibshirani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, just left some small suggestions.

@cbuescher
Copy link
Member Author

@jtibshirani thanks, I think I adressed your change requests and added a unit and a yaml test. I think I will also add a short passage to the docs somewhere about fetching flattened subfields and that the naming has to be exact, I haven't found a good spot yet though. Will be back with another short update shortly.

Copy link
Contributor

@jtibshirani jtibshirani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me! I added some last minor comments.

@@ -325,6 +325,77 @@ will return only the users first name but still maintain the structure of the ne
However, when the `fields` pattern targets the nested `user` field directly, no
values will be returned since the pattern doesn't match any leaf fields.

[discrete]
[[search-fields-flattened]]
==== Handling of flattened fields
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to move this to the flattened field type documentation. That would help keep this high-level documentation streamlined and easy to approach.

@@ -261,8 +263,7 @@ public BytesRef indexedValueForSearch(Object value) {

@Override
public ValueFetcher valueFetcher(SearchExecutionContext context, String format) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized we should throw an error if the format is non-null, as we do for most other field types. (This is unfortunately very manual right now and easy to forget...)

Christoph Büscher added 2 commits April 14, 2021 21:34
Copy link
Contributor

@romseygeek romseygeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the iterations @cbuescher

@cbuescher cbuescher merged commit 948d02e into elastic:master Apr 15, 2021
cbuescher pushed a commit to cbuescher/elasticsearch that referenced this pull request Apr 15, 2021
Currently the `fields` API fetches the root flattened field and returns it in a
structured way in the response. In addition this change makes it possible to
directly query subfields. However, requesting flattened subfields via wildcard
patterns is not possible.

Closes elastic#70605
cbuescher pushed a commit that referenced this pull request Apr 15, 2021
Currently the `fields` API fetches the root flattened field and returns it in a
structured way in the response. In addition this change makes it possible to
directly query subfields. However, requesting flattened subfields via wildcard
patterns is not possible.

Closes #70605
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Meta label for search team v7.13.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support fetching flattened subfields
5 participants