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

Mappings: Allow to force dots in field names #19937

Merged
merged 1 commit into from
Aug 11, 2016

Conversation

rjernst
Copy link
Member

@rjernst rjernst commented Aug 11, 2016

With the changes in 5.0 to allow dots in field names for documents as
well as mappings, we now have the possibility to allow a path forward
for users which must have dots in fields on 2.x. This change adds an
option to override the dot checks, mapper.allow_dots_in_name which may
be set to true to omit the dots in field names error check. The
resulting mappings will contain dots in the field names, and on upgrade
to 5.x, those will be automatically converted to object mappings on
startup.

Note that this works because the underlying lucene indexes uses the full
path. If a luser uses this to produce corrupt mappings, for example, two
fields foo and foo.bar which are both text, the upgrade to 5.x will
fail (because foo cannot be an object as well as a string field).

One open question is how to test. I've checked that this upgrade path works manually. I don't think a unit test will work (would depend on a sysprop being set which we should not generally have set in tests). I think the best way would be to add a special case in the bwc generation script, so that 2.4 indexes will have a field name with dot, and then the normal static bwc index tests will check that the upgrade works.

With the changes in 5.0 to allow dots in field names for documents as
well as mappings, we now have the possibility to allow a path forward
for users which must have dots in fields on 2.x. This change adds an
option to override the dot checks, `mapper.allow_dots_in_name` which may
be set to `true` to omit the dots in field names error check. The
resulting mappings will contain dots in the field names, and on upgrade
to 5.x, those will be automatically converted to object mappings on
startup.

Note that this works because the underlying lucene indexes uses the full
path. If a user users this to produce corrupt mappings, for example, two
fields `foo` and `foo.bar` which are both text, the upgrade to 5.x will
fail (because `foo` cannot be an object as well as a string field).
@rjernst rjernst added :Search Foundations/Mapping Index mappings, including merging and defining field types v2.4.0 labels Aug 11, 2016
@jpountz
Copy link
Contributor

jpountz commented Aug 11, 2016

I think the best way would be to add a special case in the bwc generation script, so that 2.4 indexes will have a field name with dot, and then the normal static bwc index tests will check that the upgrade works.

+1

@rjernst
Copy link
Member Author

rjernst commented Aug 11, 2016

I created #19956 so we don't forget to add the change to static bwc indexes.

@rjernst rjernst merged commit 69db1c1 into elastic:2.4 Aug 11, 2016
@rjernst rjernst deleted the dots_in_mappers branch August 11, 2016 15:47
@s1monw s1monw mentioned this pull request Aug 22, 2016
@clintongormley
Copy link
Contributor

@rjernst this setting isn't documented anywhere - could you add to the 2.4 docs please?

@derjohn
Copy link

derjohn commented Sep 5, 2016

+1 Yeah!

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 v2.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants