forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Give precedence to index creation when mixing typed templates with ty…
…peless index creation and vice-versa. Currently if you mix typed templates and typeless index creation or typeless templates and typed index creation then you will end up with an error because Elasticsearch tries to create an index that has multiple types: `_doc` and the explicit type name that you used. This commit proposes to give precedence to the index creation call so that the type from the template will be ignored if the index creation call is typeless while the template is typed, and the type from the index creation call will be used if there is a typeless template. This is consistent with the fact that index creation already "wins" if a field is defined differently in the index creation call and in a template: the definition from the index creation call is used in such cases. Closes elastic#37773
- Loading branch information
Showing
2 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
...api-spec/src/main/resources/rest-api-spec/test/indices.create/20_mix_typeless_typeful.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
--- | ||
"Create a typeless index while there is a typed template": | ||
|
||
- skip: | ||
version: " - 6.99.99" | ||
reason: needs change to be backported to 6.7 | ||
|
||
- do: | ||
indices.put_template: | ||
include_type_name: true | ||
name: test_template | ||
body: | ||
index_patterns: test-* | ||
mappings: | ||
my_type: | ||
properties: | ||
foo: | ||
type: keyword | ||
|
||
- do: | ||
indices.create: | ||
include_type_name: false | ||
index: test-1 | ||
body: | ||
mappings: | ||
properties: | ||
bar: | ||
type: "long" | ||
|
||
- do: | ||
indices.get_mapping: | ||
include_type_name: true | ||
index: test-1 | ||
|
||
- is_true: test-1.mappings._doc # the index creation call won | ||
- is_false: test-1.mappings.my_type | ||
- is_true: test-1.mappings._doc.properties.foo | ||
- is_true: test-1.mappings._doc.properties.bar | ||
|
||
--- | ||
"Create a typed index while there is a typeless template": | ||
|
||
- skip: | ||
version: " - 6.99.99" | ||
reason: needs change to be backported to 6.7 | ||
|
||
- do: | ||
indices.put_template: | ||
include_type_name: false | ||
name: test_template | ||
body: | ||
index_patterns: test-* | ||
mappings: | ||
properties: | ||
foo: | ||
type: keyword | ||
|
||
- do: | ||
indices.create: | ||
include_type_name: true | ||
index: test-1 | ||
body: | ||
mappings: | ||
my_type: | ||
properties: | ||
bar: | ||
type: "long" | ||
|
||
- do: | ||
indices.get_mapping: | ||
include_type_name: true | ||
index: test-1 | ||
|
||
- is_true: test-1.mappings.my_type # the index creation call won | ||
- is_false: test-1.mappings._doc | ||
- is_true: test-1.mappings.my_type.properties.foo | ||
- is_true: test-1.mappings.my_type.properties.bar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters