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.
Add an
include_type_name
option. (elastic#29453)
This adds an `include_type_name` option to the `indices.create`, `indices.get_mapping` and `indices.put_mapping` APIs, which defaults to `true`. When set to `false`, then mappings will be returned directly in the body of the `indices.get_mapping` API, without keying them by the type name, the `indices.create` will expect mappings directly under the `mappings` key, and the `indices.put_mapping` will use `_doc` as a type name and fail if a `type` is provided explicitly. On 5.x indices, get-mapping will fail if the index has multiple mappings, and put-mapping will update or introduce mappings for the `_doc` type instead of updating existing mappings. This oddity is required so that we don't have to introduce a new flag to put-mapping requests to know whether they are actually updating the `_doc` type or performing a typeless call. Relates elastic#15613
- Loading branch information
Showing
15 changed files
with
442 additions
and
10 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
23 changes: 23 additions & 0 deletions
23
...pec/src/main/resources/rest-api-spec/test/indices.get_mapping/70_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,23 @@ | ||
--- | ||
"GET mapping with typeless API on an index that has types": | ||
|
||
- skip: | ||
version: " - 6.6.99" | ||
reason: include_type_name was introduced in 6.7.0 | ||
|
||
- do: | ||
indices.create: # not using include_type_name: false on purpose | ||
index: index | ||
body: | ||
mappings: | ||
not_doc: | ||
properties: | ||
foo: | ||
type: "keyword" | ||
|
||
- do: | ||
indices.get_mapping: | ||
include_type_name: false | ||
index: index | ||
|
||
- match: { index.mappings.properties.foo.type: "keyword" } |
52 changes: 52 additions & 0 deletions
52
...pec/src/main/resources/rest-api-spec/test/indices.put_mapping/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,52 @@ | ||
--- | ||
"PUT mapping with typeless API on an index that has types": | ||
|
||
- skip: | ||
version: " - 6.6.99" | ||
reason: include_type_name was introduced in 6.7.0 | ||
|
||
- do: | ||
indices.create: # not using include_type_name: false on purpose | ||
index: index | ||
body: | ||
mappings: | ||
not_doc: | ||
properties: | ||
foo: | ||
type: "keyword" | ||
|
||
- do: | ||
indices.put_mapping: | ||
include_type_name: false | ||
index: index | ||
body: | ||
properties: | ||
bar: | ||
type: "long" | ||
|
||
- do: | ||
indices.get_mapping: | ||
include_type_name: false | ||
index: index | ||
|
||
- match: { index.mappings.properties.foo.type: "keyword" } | ||
- match: { index.mappings.properties.bar.type: "long" } | ||
|
||
- do: | ||
indices.put_mapping: | ||
include_type_name: false | ||
index: index | ||
body: | ||
properties: | ||
foo: | ||
type: "keyword" # also test no-op updates that trigger special logic wrt the mapping version | ||
|
||
- do: | ||
catch: bad_request | ||
indices.put_mapping: | ||
index: index | ||
body: | ||
some_other_type: | ||
properties: | ||
bar: | ||
type: "long" |
Oops, something went wrong.