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

Only allow one type on 6.0 indices #24317

Merged
merged 7 commits into from
Apr 27, 2017

Conversation

jpountz
Copy link
Contributor

@jpountz jpountz commented Apr 25, 2017

This adds the index.mapping.single_type setting, which enforces that indices
have at most one type when it is true. The default value is true for 6.0+ indices
and false for old indices.

Most of the change is about fixing tests that created multiple types to either
create a single _type instead or set index.mapping.single_type to false
(eg. for parent/child tests, which still require multiple types).

Relates #15613

When `false`, indices are not allowed to have more than one type. This property
is `false` by default for indices created on or after 7.0 and `true` by default
on older versions.

Most of the change is about fixing tests that created multiple types to either
create a single `_type` instead or enable the `_type` mapper.

Relates elastic#15613
@jpountz jpountz added :Search Foundations/Mapping Index mappings, including merging and defining field types >breaking >enhancement v5.5.0 v6.0.0-alpha1 labels Apr 25, 2017
@jpountz
Copy link
Contributor Author

jpountz commented Apr 26, 2017

Note to reviewers: the PR is a bit large but you can focus on changes in MapperService.java, TypeFieldMapper.java, MapperServiceTests.java and TypeFieldMapperTests.java. Other changes are just about fixing tests so that they pass.

@jpountz
Copy link
Contributor Author

jpountz commented Apr 26, 2017

@martijnvg @jimczi Maybe you could have a look since it is a bit related to #20257. What I have been doing for now with parent/child tests was just to enable the _type field in the tests.

@rjernst
Copy link
Member

rjernst commented Apr 26, 2017

I think maybe having this on _type will be confusing for users, and that it would be cleaner (both for users, and code wise) for this to be an index setting. Having it be enabled/disabled on the _type field has a sense that one could have it set differently for different document types, but in fact the entire point is it must be set to true on all of them, or false on the one type.

@clintongormley
Copy link

@rjernst good point - i'm happy to go with an index setting

@jpountz
Copy link
Contributor Author

jpountz commented Apr 26, 2017

I'll go with index.mapper.single_type if that works for everyone.

@jpountz
Copy link
Contributor Author

jpountz commented Apr 26, 2017

Done. I actually went with index.mapping.single_type since we only had one setting prefixed by index.mapper while the other ones are prefixed by index.mapping.

@jpountz jpountz changed the title Add an enabled property on _type. Only allow one type on 7.0 indices Apr 26, 2017
Copy link
Contributor

@jimczi jimczi left a comment

Choose a reason for hiding this comment

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

LGTM

@jpountz
Copy link
Contributor Author

jpountz commented Apr 27, 2017

I will merge this PR with a default value of false for now to give people who directly test against master a grace period they can use to set index.mapping.single_type on indices that still use multiple types.

@jpountz jpountz merged commit 1be2800 into elastic:master Apr 27, 2017
@jpountz jpountz deleted the enhancement/single_type branch April 27, 2017 06:43
@jpountz jpountz changed the title Only allow one type on 7.0 indices Only allow one type on 6.0 indices Apr 27, 2017
jpountz added a commit that referenced this pull request Apr 27, 2017
This adds the `index.mapping.single_type` setting, which enforces that indices
have at most one type when it is true. The default value is `false`.

Relates #15613
jpountz added a commit to jpountz/elasticsearch that referenced this pull request May 2, 2017
This is a follow-up to elastic#24317, which did the hard work but was merged in such a
way that it exposes the setting while still allowing indices to have multiple
types by default in order to give time to people who test against master to
add this setting to their index settings.
@jpountz jpountz removed the >breaking label May 2, 2017
@jpountz
Copy link
Contributor Author

jpountz commented May 2, 2017

Removing the breaking label since the actual break comes in #24428.

jpountz added a commit that referenced this pull request May 4, 2017
This is a follow-up to #24317, which did the hard work but was merged in such a
way that it exposes the setting while still allowing indices to have multiple
types by default in order to give time to people who test against master to
add this setting to their index settings.
@kukuxiahuni
Copy link

I have a question。 now my index and type used like this, bussiness_index/2017-11-12,bussiness_index/2017-11-13. just one index and more type.the type was every date string, and each type store the data of that day. when only one type in a index, how can i change my index structure??

@jpountz
Copy link
Contributor Author

jpountz commented Nov 29, 2017

You cannot change the index structure in a single type. This kind of problem is typically solved by having time-based indices rather than types.

Note: please use discuss.elastic.co to ask questions rather than Github.

bleskes added a commit that referenced this pull request Mar 22, 2018
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 v5.5.0 v6.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants