Skip to content

Conversation

@jpountz
Copy link
Contributor

@jpountz jpountz commented Nov 30, 2015

We have a bug when updating an existing mapping and the mapping update conflicts
with another type. In such a case, the mapping is already partially applied
before we raise the exception, which can lead to all sorts of bugs.

This commit moves the compatibility checks up-front so that we don't start
applying a mapping before we are sure that it is not only applicable to the
current type but also to other types.

Note that this might break compatibility for some users: we had some tests
that checked that fields that did not have a conflict were added even though
other fields from the same mapping update were not compatible. This does not
work anymore.

MapperService.merge has been refactored to take a map of mapping updates so
that we can perform some cross-type validation (necessary for _parent) that
was previously spread in-between MapperService and MetaDataMappingService.

We now also verify that fields are defined only once in a given mapping. It
was previously possible to have a field twice either by reusing the name of
a metadata mapper or by using subfields both explicitly in a plugin and in
the code of a field mapper.

The check that _parent can't point to an existing type would only be actually
applied if the master node has mappings locally. So for instance in case of
dedicated master nodes, it would be ignored. This is fixed now by adding
mappings from all types when an index does not exist locally, instead of only
mappings from the types that are being updated.

We have a bug when updating an existing mapping and the mapping update conflicts
with another type. In such a case, the mapping is already partially applied
before we raise the exception, which can lead to all sorts of bugs.

This commit moves the compatibility checks up-front so that we don't start
applying a mapping before we are sure that it is not only applicable to the
current type but also to other types.

Note that this might break compatibility for some users: we had some tests
that checked that fields that did not have a conflict were added even though
other fields from the same mapping update were not compatible. This does not
work anymore.

MapperService.merge has been refactored to take a map of mapping updates so
that we can perform some cross-type validation (necessary for _parent) that
was previously spread in-between MapperService and MetaDataMappingService.

We now also verify that fields are defined only once in a given mapping. It
was previously possible to have a field twice either by reusing the name of
a metadata mapper or by using subfields both explicitly in a plugin and in
the code of a field mapper.

The check that _parent can't point to an existing type would only be actually
applied if the master node has mappings locally. So for instance in case of
dedicated master nodes, it would be ignored. This is fixed now by adding
mappings from all types when an index does not exist locally, instead of only
mappings from the types that are being updated.
@jpountz jpountz added >bug :Search Foundations/Mapping Index mappings, including merging and defining field types labels Nov 30, 2015
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we could avoid compressing just to pass to the mapper service? Seems like the api for merge could take non compressed and we can use helpers to wrap a decompressor when we already have compressed? Just a thought for a spinoff issue (Ive had it on my mind for a while).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, there are so many places where we compress just to be able to merge the mapping!

@rjernst
Copy link
Member

rjernst commented Nov 30, 2015

This looks great! Just left a couple questions, but as is this change looks good to me to push.

@jpountz
Copy link
Contributor Author

jpountz commented Dec 1, 2015

As per @s1monw 's and @bleskes 's request, I will split this PR into smaller PRs.

@jpountz jpountz closed this Dec 1, 2015
@jpountz
Copy link
Contributor Author

jpountz commented Dec 1, 2015

Here is a PR to fix an issue with cross-type validation for _parent: #15142

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>bug :Search Foundations/Mapping Index mappings, including merging and defining field types

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants