-
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 typeless APIs usable with indices whose type name is different f…
…rom `_doc` (#35790) This commit makes `document`, `update`, `explain`, `termvectors` and `mapping` typeless APIs work on indices that have a type whose name is not `_doc`. Unfortunately, this needs to be a bit of a hack since I didn't want calls with random type names to see documents with the type name that the user had chosen upon type creation. The `explain` and `termvectors` do not support being called without a type for now so the test is just using `_doc` as a type for now, we will need to fix tests later but this shouldn't require further changes server-side since passing `_doc` as a type name is what typeless APIs do internally anyway. Relates #35190
- Loading branch information
Showing
36 changed files
with
747 additions
and
113 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
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,34 @@ | ||
--- | ||
"bulk without types on an index that has types": | ||
|
||
- skip: | ||
version: " - 6.99.99" | ||
reason: Typeless APIs were introduced in 7.0.0 | ||
|
||
- do: | ||
indices.create: # not using include_type_name: false on purpose | ||
index: index | ||
body: | ||
mappings: | ||
not_doc: | ||
properties: | ||
foo: | ||
type: "keyword" | ||
- do: | ||
bulk: | ||
refresh: true | ||
body: | ||
- index: | ||
_index: index | ||
_id: 0 | ||
- foo: bar | ||
- index: | ||
_index: index | ||
_id: 1 | ||
- foo: bar | ||
|
||
- do: | ||
count: | ||
index: index | ||
|
||
- match: {count: 2} |
42 changes: 42 additions & 0 deletions
42
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,42 @@ | ||
--- | ||
"DELETE with typeless API on an index that has types": | ||
|
||
- skip: | ||
version: " - 6.99.99" | ||
reason: Typeless APIs were introduced in 7.0.0 | ||
|
||
- do: | ||
indices.create: # not using include_type_name: false on purpose | ||
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 | ||
id: 1 | ||
|
||
- match: { _index: "index" } | ||
- match: { _type: "_doc" } | ||
- match: { _id: "1"} | ||
- match: { _version: 2} |
56 changes: 56 additions & 0 deletions
56
rest-api-spec/src/main/resources/rest-api-spec/test/explain/40_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,56 @@ | ||
--- | ||
"Explain with typeless API on an index that has types": | ||
|
||
- skip: | ||
version: " - 6.99.99" | ||
reason: Typeless APIs were introduced in 7.0.0 | ||
|
||
- do: | ||
indices.create: # not using include_type_name: false on purpose | ||
index: index | ||
body: | ||
mappings: | ||
not_doc: | ||
properties: | ||
foo: | ||
type: "keyword" | ||
|
||
- do: | ||
index: | ||
index: index | ||
type: not_doc | ||
id: 1 | ||
body: { foo: bar } | ||
|
||
- do: | ||
indices.refresh: {} | ||
|
||
- do: | ||
catch: missing | ||
explain: | ||
index: index | ||
type: some_random_type | ||
id: 1 | ||
body: | ||
query: | ||
match_all: {} | ||
|
||
- match: { _index: "index" } | ||
- match: { _type: "some_random_type" } | ||
- match: { _id: "1"} | ||
- match: { matched: false} | ||
|
||
- do: | ||
explain: | ||
index: index | ||
type: _doc #todo: make _explain typeless and remove this | ||
id: 1 | ||
body: | ||
query: | ||
match_all: {} | ||
|
||
- match: { _index: "index" } | ||
- match: { _type: "_doc" } | ||
- match: { _id: "1"} | ||
- is_true: matched | ||
- match: { explanation.value: 1 } |
46 changes: 46 additions & 0 deletions
46
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,46 @@ | ||
--- | ||
"GET with typeless API on an index that has types": | ||
|
||
- skip: | ||
version: " - 6.99.99" | ||
reason: Typeless APIs were introduced in 7.0.0 | ||
|
||
- do: | ||
indices.create: # not using include_type_name: false on purpose | ||
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 | ||
id: 1 | ||
|
||
- match: { _index: "index" } | ||
- match: { _type: "_doc" } | ||
- match: { _id: "1"} | ||
- match: { _version: 1} | ||
- match: { _source: { foo: bar }} |
62 changes: 62 additions & 0 deletions
62
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,62 @@ | ||
--- | ||
"Index with typeless API on an index that has types": | ||
|
||
- skip: | ||
version: " - 6.99.99" | ||
reason: Typeless APIs were introduced in 7.0.0 | ||
|
||
- do: | ||
indices.create: # not using include_type_name: false on purpose | ||
index: index | ||
body: | ||
mappings: | ||
not_doc: | ||
properties: | ||
foo: | ||
type: "keyword" | ||
|
||
- do: | ||
index: | ||
index: index | ||
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 | ||
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 }} |
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.99.99" | ||
reason: include_type_name was introduced in 7.0.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.99.99" | ||
reason: include_type_name was introduced in 7.0.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" |
32 changes: 32 additions & 0 deletions
32
rest-api-spec/src/main/resources/rest-api-spec/test/mtermvectors/30_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,32 @@ | ||
--- | ||
"mtermvectors without types on an index that has types": | ||
|
||
- skip: | ||
version: " - 6.99.99" | ||
reason: Typeless APIs were introduced in 7.0.0 | ||
|
||
- do: | ||
indices.create: # not using include_type_name: false on purpose | ||
index: index | ||
body: | ||
mappings: | ||
not_doc: | ||
properties: | ||
foo: | ||
type : "text" | ||
term_vector : "with_positions_offsets" | ||
|
||
- do: | ||
index: | ||
index: index | ||
id: 1 | ||
body: { foo: bar } | ||
|
||
- do: | ||
mtermvectors: | ||
body: | ||
docs: | ||
- _index: index | ||
_id: 1 | ||
|
||
- match: {docs.0.term_vectors.foo.terms.bar.term_freq: 1} |
Oops, something went wrong.