-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make
_doc
work as an alias of the actual type of an index. (#39505)
This is similar to the work that has been done on 7.x to make typeless API calls work on indices that have types, except that this commit doesn't introduce typeless calls, eg. the REST API spec or REST handlers haven't been updated. It only affects the get, index, update, delete and bulk APIs. Other APIs that require types such as explain or termvectors are left unchanged. This is necesarry to allow for rolling upgrades from 6.7 to 7.x while internal indices might remain queried during upgrade by nodes that are on either version. Closes #39469
- Loading branch information
Showing
22 changed files
with
669 additions
and
33 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
rest-api-spec/src/main/resources/rest-api-spec/test/bulk/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,37 @@ | ||
--- | ||
"bulk without types on an index that has types": | ||
|
||
- skip: | ||
version: " - 6.6.99" | ||
reason: Typeless APIs were introduced in 6.7.0 | ||
|
||
- do: | ||
indices.create: # not using include_type_name: false on purpose | ||
include_type_name: true | ||
index: index | ||
body: | ||
mappings: | ||
not_doc: | ||
properties: | ||
foo: | ||
type: "keyword" | ||
- do: | ||
bulk: | ||
refresh: true | ||
body: | ||
- index: | ||
_index: index | ||
_type: _doc | ||
_id: 0 | ||
- foo: bar | ||
- index: | ||
_index: index | ||
_type: _doc | ||
_id: 1 | ||
- foo: bar | ||
|
||
- do: | ||
count: | ||
index: index | ||
|
||
- match: {count: 2} |
44 changes: 44 additions & 0 deletions
44
rest-api-spec/src/main/resources/rest-api-spec/test/delete/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,44 @@ | ||
--- | ||
"DELETE with typeless API on an index that has types": | ||
|
||
- skip: | ||
version: " - 6.6.99" | ||
reason: Typeless APIs were introduced in 6.7.0 | ||
|
||
- do: | ||
indices.create: # not using include_type_name: false on purpose | ||
include_type_name: true | ||
index: index | ||
body: | ||
mappings: | ||
not_doc: | ||
properties: | ||
foo: | ||
type: "keyword" | ||
|
||
- do: | ||
index: | ||
index: index | ||
type: not_doc | ||
id: 1 | ||
body: { foo: bar } | ||
|
||
- do: | ||
catch: bad_request | ||
delete: | ||
index: index | ||
type: some_random_type | ||
id: 1 | ||
|
||
- match: { error.root_cause.0.reason: "/Rejecting.mapping.update.to.\\[index\\].as.the.final.mapping.would.have.more.than.1.type.*/" } | ||
|
||
- do: | ||
delete: | ||
index: index | ||
type: _doc | ||
id: 1 | ||
|
||
- match: { _index: "index" } | ||
- match: { _type: "_doc" } | ||
- match: { _id: "1"} | ||
- match: { _version: 2} |
48 changes: 48 additions & 0 deletions
48
rest-api-spec/src/main/resources/rest-api-spec/test/get/100_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,48 @@ | ||
--- | ||
"GET with typeless API on an index that has types": | ||
|
||
- skip: | ||
version: " - 6.6.99" | ||
reason: Typeless APIs were introduced in 6.7.0 | ||
|
||
- do: | ||
indices.create: # not using include_type_name: false on purpose | ||
include_type_name: true | ||
index: index | ||
body: | ||
mappings: | ||
not_doc: | ||
properties: | ||
foo: | ||
type: "keyword" | ||
|
||
- do: | ||
index: | ||
index: index | ||
type: not_doc | ||
id: 1 | ||
body: { foo: bar } | ||
|
||
- do: | ||
catch: missing | ||
get: | ||
index: index | ||
type: some_random_type | ||
id: 1 | ||
|
||
- match: { _index: "index" } | ||
- match: { _type: "some_random_type" } | ||
- match: { _id: "1"} | ||
- match: { found: false} | ||
|
||
- do: | ||
get: | ||
index: index | ||
type: _doc | ||
id: 1 | ||
|
||
- match: { _index: "index" } | ||
- match: { _type: "_doc" } | ||
- match: { _id: "1"} | ||
- match: { _version: 1} | ||
- match: { _source: { foo: bar }} |
105 changes: 105 additions & 0 deletions
105
rest-api-spec/src/main/resources/rest-api-spec/test/index/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,105 @@ | ||
--- | ||
"Index with typeless API on an index that has types": | ||
|
||
- skip: | ||
version: " - 6.6.99" | ||
reason: Typeless APIs were introduced in 6.7.0 | ||
|
||
- do: | ||
indices.create: # not using include_type_name: false on purpose | ||
include_type_name: true | ||
index: index | ||
body: | ||
mappings: | ||
not_doc: | ||
properties: | ||
foo: | ||
type: "keyword" | ||
|
||
- do: | ||
index: | ||
index: index | ||
type: _doc | ||
id: 1 | ||
body: { foo: bar } | ||
|
||
- match: { _index: "index" } | ||
- match: { _type: "_doc" } | ||
- match: { _id: "1"} | ||
- match: { _version: 1} | ||
|
||
- do: | ||
get: # not using typeless API on purpose | ||
index: index | ||
type: not_doc | ||
id: 1 | ||
|
||
- match: { _index: "index" } | ||
- match: { _type: "not_doc" } # the important bit to check | ||
- match: { _id: "1"} | ||
- match: { _version: 1} | ||
- match: { _source: { foo: bar }} | ||
|
||
|
||
- do: | ||
index: | ||
index: index | ||
type: _doc | ||
body: { foo: bar } | ||
|
||
- match: { _index: "index" } | ||
- match: { _type: "_doc" } | ||
- match: { _version: 1} | ||
- set: { _id: id } | ||
|
||
- do: | ||
get: # using typeful API on purpose | ||
index: index | ||
type: not_doc | ||
id: '$id' | ||
|
||
- match: { _index: "index" } | ||
- match: { _type: "not_doc" } # the important bit to check | ||
- match: { _id: $id} | ||
- match: { _version: 1} | ||
- match: { _source: { foo: bar }} | ||
|
||
--- | ||
"Index call that introduces new field mappings": | ||
|
||
- skip: | ||
version: " - 6.6.99" | ||
reason: Typeless APIs were introduced in 6.7.0 | ||
|
||
- do: | ||
indices.create: # not using include_type_name: false on purpose | ||
include_type_name: true | ||
index: index | ||
body: | ||
mappings: | ||
not_doc: | ||
properties: | ||
foo: | ||
type: "keyword" | ||
- do: | ||
index: | ||
index: index | ||
type: _doc | ||
id: 2 | ||
body: { new_field: value } | ||
|
||
- match: { _index: "index" } | ||
- match: { _type: "_doc" } | ||
- match: { _id: "2" } | ||
- match: { _version: 1 } | ||
|
||
- do: | ||
get: # using typeful API on purpose | ||
index: index | ||
type: not_doc | ||
id: 2 | ||
|
||
- match: { _index: "index" } | ||
- match: { _type: "not_doc" } | ||
- match: { _id: "2" } | ||
- match: { _version: 1} |
File renamed without changes.
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
88 changes: 88 additions & 0 deletions
88
rest-api-spec/src/main/resources/rest-api-spec/test/update/90_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,88 @@ | ||
--- | ||
"Update with typeless API on an index that has types": | ||
|
||
- skip: | ||
version: " - 6.6.99" | ||
reason: Typeless APIs were introduced in 6.7.0 | ||
|
||
- do: | ||
indices.create: # not using include_type_name: false on purpose | ||
include_type_name: true | ||
index: index | ||
body: | ||
mappings: | ||
not_doc: | ||
properties: | ||
foo: | ||
type: "keyword" | ||
|
||
- do: | ||
index: | ||
index: index | ||
type: not_doc | ||
id: 1 | ||
body: { foo: bar } | ||
|
||
- do: | ||
update: | ||
index: index | ||
type: _doc | ||
id: 1 | ||
body: | ||
doc: | ||
foo: baz | ||
|
||
- do: | ||
get: | ||
index: index | ||
type: not_doc | ||
id: 1 | ||
|
||
- match: { _source.foo: baz } | ||
|
||
--- | ||
"Update call that introduces new field mappings": | ||
|
||
- skip: | ||
version: " - 6.7.99" | ||
reason: Typeless APIs were introduced in 6.7.0 | ||
|
||
- do: | ||
indices.create: # not using include_type_name: false on purpose | ||
include_type_name: true | ||
index: index | ||
body: | ||
mappings: | ||
not_doc: | ||
properties: | ||
foo: | ||
type: "keyword" | ||
|
||
- do: | ||
index: | ||
index: index | ||
type: not_doc | ||
id: 1 | ||
body: { foo: bar } | ||
|
||
- do: | ||
update: | ||
index: index | ||
type: _doc | ||
id: 1 | ||
body: | ||
doc: | ||
foo: baz | ||
new_field: value | ||
- do: | ||
get: # using typeful API on purpose | ||
index: index | ||
type: not_doc | ||
id: 1 | ||
|
||
- match: { _index: "index" } | ||
- match: { _type: "not_doc" } | ||
- match: { _id: "1" } | ||
- match: { _version: 2} | ||
- match: { _source.foo: baz } | ||
- match: { _source.new_field: value } |
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
Oops, something went wrong.