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.
Make typeless APIs usable with indices whose type name is different f…
…rom `_doc`. 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 elastic#35190
- Loading branch information
Showing
19 changed files
with
522 additions
and
43 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
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,40 @@ | ||
--- | ||
"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 | ||
|
||
- 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" } |
43 changes: 43 additions & 0 deletions
43
...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,43 @@ | ||
--- | ||
"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: | ||
catch: bad_request | ||
indices.put_mapping: | ||
index: index | ||
body: | ||
some_other_type: | ||
properties: | ||
bar: | ||
type: "long" |
45 changes: 45 additions & 0 deletions
45
rest-api-spec/src/main/resources/rest-api-spec/test/termvectors/50_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,45 @@ | ||
--- | ||
"Term vectors 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: "text" | ||
term_vector: "with_positions" | ||
|
||
- do: | ||
index: | ||
index: index | ||
type: not_doc | ||
id: 1 | ||
body: { foo: bar } | ||
|
||
- do: | ||
indices.refresh: {} | ||
|
||
- do: | ||
termvectors: | ||
index: index | ||
type: _doc # todo: remove when termvectors support typeless API | ||
id: 1 | ||
|
||
- is_true: found | ||
- match: {_type: _doc} | ||
- match: {term_vectors.foo.terms.bar.term_freq: 1} | ||
|
||
- do: | ||
termvectors: | ||
index: index | ||
type: some_random_type | ||
id: 1 | ||
|
||
- is_false: found |
39 changes: 39 additions & 0 deletions
39
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,39 @@ | ||
--- | ||
"Update 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: | ||
update: | ||
index: index | ||
id: 1 | ||
body: | ||
doc: | ||
foo: baz | ||
|
||
- do: | ||
get: | ||
index: index | ||
type: not_doc | ||
id: 1 | ||
|
||
- match: { _source.foo: baz } |
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.