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

[7.x] Allow metadata fields in the _source #62616

Merged
merged 2 commits into from
Sep 18, 2020

Conversation

csoulios
Copy link
Contributor

Backports #61590 to 7.x

So far we don't allow metadata fields in the document _source. However, in the case of the _doc_count field mapper (#58339) we want to be able to set

This PR adds a method to the metadata field parsers that exposes if the field can be included in the document source or not.
This way each metadata field can configure if it can be included in the document _source

csoulios and others added 2 commits September 18, 2020 10:01
* Configurable metadata field mappers in the _source

* Changes to support metadata fields in _source
Added test testDocumentContainsAllowedMetadataField()

* Merged DocumentParserTests from master
Fixed broken tests

* Handle non string values

* Allow metadata fields to parse values/objects/arrays/null

* Removed MetadataFieldMapper.isAllowedInSource() method

Delegated this functionality to MetadataFieldMapper.parse()

* Fixed bug that caused tests to break

* Cleanup parsing for existing metadata fields

* Cleanup parsing for existing metadata fields

* Remove doParse() method

* Fix broken test

* Lookup metadata mapper by name

Instead of linear scan
@csoulios csoulios added :Search Foundations/Mapping Index mappings, including merging and defining field types backport labels Sep 18, 2020
@elasticmachine
Copy link
Collaborator

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

@elasticmachine elasticmachine added the Team:Search Meta label for search team label Sep 18, 2020
@csoulios
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/2

@csoulios csoulios merged commit 6a29897 into elastic:7.x Sep 18, 2020
@csoulios csoulios deleted the metadata-source-7.x branch September 18, 2020 16:56
romseygeek added a commit that referenced this pull request May 6, 2021
#62616 refactored how we deal with building mapping updates for
delete operations against an empty index. In 7x, delete operations
include a type as part of the operation UID, and this type needs to
be resolved against mappings. In particular, the type _doc can
mean either a type called _doc (the general case), or it can mean
whatever type this index actually has. There are two code paths
in IndexShard.applyDeleteOperation, one for empty mappings
and one for the standard case; #62616 was resolving the type for
the first code path, but not the second, which meant that some
delete operations could be written to the translog with an incorrect
type.

This commit adds type resolution to the second code path as well.

Fixes #72735
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Meta label for search team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants