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

Handle metadata fields in search 'fields' option #63569

Closed
jtibshirani opened this issue Oct 12, 2020 · 5 comments
Closed

Handle metadata fields in search 'fields' option #63569

jtibshirani opened this issue Oct 12, 2020 · 5 comments
Assignees
Labels
>enhancement :Search/Search Search-related issues that do not fall into other categories Team:Search Meta label for search team

Comments

@jtibshirani
Copy link
Contributor

Currently the search 'fields' option skips over metadata fields. It would be great to add support for them, to help make 'fields' the central place to retrieve document content.

Some specific improvements:

An open question: should only return metadata fields if they're explicitly requested, or allow wildcard patterns like * to match them?

@jtibshirani jtibshirani added >enhancement :Search/Search Search-related issues that do not fall into other categories labels Oct 12, 2020
@elasticmachine
Copy link
Collaborator

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

@jtibshirani
Copy link
Contributor Author

We discussed this as a group, and agreed we'd only like to return metadata fields if they're explicitly requested. They will not be returned when requesting "fields": ["*"].

@cbuescher cbuescher self-assigned this Mar 18, 2021
cbuescher pushed a commit to cbuescher/elasticsearch that referenced this issue Mar 18, 2021
Currently metadata fields like `_size` or `_doc_count` cannot be retrieved using
the fields API. With this change, we allow this if the field is explicitely
queried for using its name, but won't include metadata fields when e.g.
requesting all fields via "*".
With this change, not all metadata fields will be retrievable by using its name,
but support for "_size" and "_doc_count" (which is fetched from source) is
added. Support for other metadata field types will need to be decided case by
case and an appropriate ValueFetcher needs to be supplied.

Relates to elastic#63569
@cbuescher
Copy link
Member

I took a first look at how this might work and opened a PR with #70575. I don't know if it was already discussed, but my guess is that we want to decide which other metadata fields to support on a case-by-case basis. For example, I don't know if we want to support "_seq_no", in any case most of these field types currently don't return their own valueFetcher but throw an exception instead. We would need to change that for the fields we want to support.

@jtibshirani
Copy link
Contributor Author

jtibshirani commented Mar 30, 2021

We didn't discuss what metadata fields to return explicitly. I'm curious to hear what others think, but from my perspective, your PR is the right first step -- it covers the helpful case of _size and makes sure that all metadata fields present in _source can be retrieved. It feels less valuable to support other metadata fields like _index, _id and _routing, since these are already returned on the search hit by default. It's also not straightforward right now, since they're 'stored fields'. For _seq_no and _primary_term, these can already be requested through the seq_no_primary_term parameter.

In the future, maybe we could consider unifying the retrieval for most metadata fields through the fields option? So we wouldn't need all these specialized options like version: true and seq_no_primary_term: true. This feels like a follow-up to me though, not in scope for this issue.

cbuescher pushed a commit that referenced this issue Mar 31, 2021
Currently metadata fields like `_size` or `_doc_count` cannot be retrieved using
the fields API. With this change, we allow this if the field is explicitely
queried for using its name, but won't include metadata fields when e.g.
requesting all fields via "*".
With this change, not all metadata fields will be retrievable by using its name,
but support for "_size" and "_doc_count" (which is fetched from source) is
added. Support for other metadata field types will need to be decided case by
case and an appropriate ValueFetcher needs to be supplied.

Relates to #63569
cbuescher pushed a commit that referenced this issue Mar 31, 2021
Currently metadata fields like `_size` or `_doc_count` cannot be retrieved using
the fields API. With this change, we allow this if the field is explicitely
queried for using its name, but won't include metadata fields when e.g.
requesting all fields via "*".
With this change, not all metadata fields will be retrievable by using its name,
but support for "_size" and "_doc_count" (which is fetched from source) is
added. Support for other metadata field types will need to be decided case by
case and an appropriate ValueFetcher needs to be supplied.

Relates to #63569
jtibshirani added a commit that referenced this issue Apr 8, 2021
Now that the `fields` option allows fetching metadata fields, we can support
loading the new `_tier` metadata field.

Relates to #63569 and #68135.
jtibshirani added a commit that referenced this issue Apr 8, 2021
Now that the `fields` option allows fetching metadata fields, we can support
loading the new `_tier` metadata field.

Relates to #63569 and #68135.
@jtibshirani
Copy link
Contributor Author

I'm closing this out since we covered the issue focus:

  • We removed logic to skip over metadata fields when loading fields
  • We added support for fields that don't already have special handling on the search hit: _doc_count, _size, _tier

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Search/Search Search-related issues that do not fall into other categories Team:Search Meta label for search team
Projects
None yet
Development

No branches or pull requests

3 participants