diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/10_basic.yml index 233ff32b4184b..dc7242f28754a 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/10_basic.yml @@ -1,18 +1,22 @@ --- "Array of objects": + + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: bulk: + include_type_name: false refresh: true body: - index: _index: test_index - _type: test_type _id: test_id - f1: v1 f2: 42 - index: _index: test_index - _type: test_type _id: test_id2 - f1: v2 f2: 47 @@ -25,23 +29,26 @@ --- "Empty _id": + + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: bulk: + include_type_name: false refresh: true body: - index: _index: test - _type: type _id: '' - f: 1 - index: _index: test - _type: type _id: id - f: 2 - index: _index: test - _type: type - f: 3 - match: { errors: true } - match: { items.0.index.status: 400 } @@ -59,12 +66,17 @@ --- "empty action": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: catch: /Malformed action\/metadata line \[3\], expected FIELD_NAME but found \[END_OBJECT\]/ headers: Content-Type: application/json bulk: + include_type_name: false body: | - {"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id"}} + {"index": {"_index": "test_index", "_id": "test_id"}} {"f1": "v1", "f2": 42} {} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/11_basic_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/11_basic_with_types.yml new file mode 100644 index 0000000000000..233ff32b4184b --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/11_basic_with_types.yml @@ -0,0 +1,70 @@ +--- +"Array of objects": + - do: + bulk: + refresh: true + body: + - index: + _index: test_index + _type: test_type + _id: test_id + - f1: v1 + f2: 42 + - index: + _index: test_index + _type: test_type + _id: test_id2 + - f1: v2 + f2: 47 + + - do: + count: + index: test_index + + - match: {count: 2} + +--- +"Empty _id": + - do: + bulk: + refresh: true + body: + - index: + _index: test + _type: type + _id: '' + - f: 1 + - index: + _index: test + _type: type + _id: id + - f: 2 + - index: + _index: test + _type: type + - f: 3 + - match: { errors: true } + - match: { items.0.index.status: 400 } + - match: { items.0.index.error.type: illegal_argument_exception } + - match: { items.0.index.error.reason: if _id is specified it must not be empty } + - match: { items.1.index.result: created } + - match: { items.2.index.result: created } + + - do: + count: + index: test + + - match: { count: 2 } + +--- +"empty action": + + - do: + catch: /Malformed action\/metadata line \[3\], expected FIELD_NAME but found \[END_OBJECT\]/ + headers: + Content-Type: application/json + bulk: + body: | + {"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id"}} + {"f1": "v1", "f2": 42} + {} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/20_list_of_strings.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/20_list_of_strings.yml index def91f4280722..742cf49c38e53 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/20_list_of_strings.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/20_list_of_strings.yml @@ -1,12 +1,18 @@ --- "List of strings": + + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: bulk: + include_type_name: false refresh: true body: - - '{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id"}}' + - '{"index": {"_index": "test_index", "_id": "test_id"}}' - '{"f1": "v1", "f2": 42}' - - '{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id2"}}' + - '{"index": {"_index": "test_index", "_id": "test_id2"}}' - '{"f1": "v2", "f2": 47}' - do: diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/21_list_of_strings_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/21_list_of_strings_with_types.yml new file mode 100644 index 0000000000000..def91f4280722 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/21_list_of_strings_with_types.yml @@ -0,0 +1,17 @@ +--- +"List of strings": + - do: + bulk: + refresh: true + body: + - '{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id"}}' + - '{"f1": "v1", "f2": 42}' + - '{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id2"}}' + - '{"f1": "v2", "f2": 47}' + + - do: + count: + index: test_index + + - match: {count: 2} + diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/30_big_string.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/30_big_string.yml index 1d117253c9b01..15a70fa3f378e 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/30_big_string.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/30_big_string.yml @@ -1,12 +1,18 @@ --- "One big string": + + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: bulk: + include_type_name: false refresh: true body: | - {"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id"}} + {"index": {"_index": "test_index", "_id": "test_id"}} {"f1": "v1", "f2": 42} - {"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id2"}} + {"index": {"_index": "test_index", "_id": "test_id2"}} {"f1": "v2", "f2": 47} - do: diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/31_big_string_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/31_big_string_with_types.yml new file mode 100644 index 0000000000000..1d117253c9b01 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/31_big_string_with_types.yml @@ -0,0 +1,17 @@ +--- +"One big string": + - do: + bulk: + refresh: true + body: | + {"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id"}} + {"f1": "v1", "f2": 42} + {"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id2"}} + {"f1": "v2", "f2": 47} + + - do: + count: + index: test_index + + - match: {count: 2} + diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/40_source.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/40_source.yml index c852c376cc06f..bf4bd0795740d 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/40_source.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/40_source.yml @@ -1,37 +1,43 @@ --- "Source filtering": + + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: index: + include_type_name: false refresh: true index: test_index - type: test_type id: test_id_1 body: { "foo": "bar", "bar": "foo" } - do: index: + include_type_name: false refresh: true index: test_index - type: test_type id: test_id_2 body: { "foo": "qux", "bar": "pux" } - do: index: + include_type_name: false refresh: true index: test_index - type: test_type id: test_id_3 body: { "foo": "corge", "bar": "forge" } - do: bulk: + include_type_name: false refresh: true body: | - { "update": { "_index": "test_index", "_type": "test_type", "_id": "test_id_1", "_source": true } } + { "update": { "_index": "test_index", "_id": "test_id_1", "_source": true } } { "doc": { "foo": "baz" } } - { "update": { "_index": "test_index", "_type": "test_type", "_id": "test_id_2" } } + { "update": { "_index": "test_index", "_id": "test_id_2" } } { "_source": true, "doc": { "foo": "quux" } } - match: { items.0.update.get._source.foo: baz } @@ -39,8 +45,8 @@ - do: bulk: + include_type_name: false index: test_index - type: test_type _source: true body: | { "update": { "_id": "test_id_3" } } @@ -50,11 +56,12 @@ - do: bulk: + include_type_name: false refresh: true body: | - { "update": { "_index": "test_index", "_type": "test_type", "_id": "test_id_1", "_source": {"includes": "bar"} } } + { "update": { "_index": "test_index", "_id": "test_id_1", "_source": {"includes": "bar"} } } { "doc": { "foo": "baz" } } - { "update": { "_index": "test_index", "_type": "test_type", "_id": "test_id_2" } } + { "update": { "_index": "test_index", "_id": "test_id_2" } } { "_source": {"includes": "foo"}, "doc": { "foo": "quux" } } - match: { items.0.update.get._source.bar: foo } @@ -64,8 +71,8 @@ - do: bulk: + include_type_name: false index: test_index - type: test_type _source_include: foo body: | { "update": { "_id": "test_id_3" } } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/41_source_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/41_source_with_types.yml new file mode 100644 index 0000000000000..c852c376cc06f --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/41_source_with_types.yml @@ -0,0 +1,76 @@ +--- +"Source filtering": + - do: + index: + refresh: true + index: test_index + type: test_type + id: test_id_1 + body: { "foo": "bar", "bar": "foo" } + + - do: + index: + refresh: true + index: test_index + type: test_type + id: test_id_2 + body: { "foo": "qux", "bar": "pux" } + + - do: + index: + refresh: true + index: test_index + type: test_type + id: test_id_3 + body: { "foo": "corge", "bar": "forge" } + + + - do: + bulk: + refresh: true + body: | + { "update": { "_index": "test_index", "_type": "test_type", "_id": "test_id_1", "_source": true } } + { "doc": { "foo": "baz" } } + { "update": { "_index": "test_index", "_type": "test_type", "_id": "test_id_2" } } + { "_source": true, "doc": { "foo": "quux" } } + + - match: { items.0.update.get._source.foo: baz } + - match: { items.1.update.get._source.foo: quux } + + - do: + bulk: + index: test_index + type: test_type + _source: true + body: | + { "update": { "_id": "test_id_3" } } + { "doc": { "foo": "garply" } } + + - match: { items.0.update.get._source.foo: garply } + + - do: + bulk: + refresh: true + body: | + { "update": { "_index": "test_index", "_type": "test_type", "_id": "test_id_1", "_source": {"includes": "bar"} } } + { "doc": { "foo": "baz" } } + { "update": { "_index": "test_index", "_type": "test_type", "_id": "test_id_2" } } + { "_source": {"includes": "foo"}, "doc": { "foo": "quux" } } + + - match: { items.0.update.get._source.bar: foo } + - is_false: items.0.update.get._source.foo + - match: { items.1.update.get._source.foo: quux } + - is_false: items.1.update.get._source.bar + + - do: + bulk: + index: test_index + type: test_type + _source_include: foo + body: | + { "update": { "_id": "test_id_3" } } + { "doc": { "foo": "garply" } } + + - match: { items.0.update.get._source.foo: garply } + - is_false: items.0.update.get._source.bar + diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/50_refresh.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/50_refresh.yml index 6326b9464caa0..059794873add7 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/50_refresh.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/50_refresh.yml @@ -1,12 +1,18 @@ --- "refresh=true immediately makes changes are visible in search": + + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: bulk: + include_type_name: false refresh: true body: | - {"index": {"_index": "bulk_50_refresh_1", "_type": "test_type", "_id": "bulk_50_refresh_id1"}} + {"index": {"_index": "bulk_50_refresh_1", "_id": "bulk_50_refresh_id1"}} {"f1": "v1", "f2": 42} - {"index": {"_index": "bulk_50_refresh_1", "_type": "test_type", "_id": "bulk_50_refresh_id2"}} + {"index": {"_index": "bulk_50_refresh_1", "_id": "bulk_50_refresh_id2"}} {"f1": "v2", "f2": 47} - do: @@ -16,13 +22,19 @@ --- "refresh=empty string immediately makes changes are visible in search": + + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: bulk: + include_type_name: false refresh: "" body: | - {"index": {"_index": "bulk_50_refresh_2", "_type": "test_type", "_id": "bulk_50_refresh_id3"}} + {"index": {"_index": "bulk_50_refresh_2", "_id": "bulk_50_refresh_id3"}} {"f1": "v1", "f2": 42} - {"index": {"_index": "bulk_50_refresh_2", "_type": "test_type", "_id": "bulk_50_refresh_id4"}} + {"index": {"_index": "bulk_50_refresh_2", "_id": "bulk_50_refresh_id4"}} {"f1": "v2", "f2": 47} - do: @@ -33,13 +45,19 @@ --- "refresh=wait_for waits until changes are visible in search": + + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: bulk: + include_type_name: false refresh: wait_for body: | - {"index": {"_index": "bulk_50_refresh_3", "_type": "test_type", "_id": "bulk_50_refresh_id5"}} + {"index": {"_index": "bulk_50_refresh_3", "_id": "bulk_50_refresh_id5"}} {"f1": "v1", "f2": 42} - {"index": {"_index": "bulk_50_refresh_3", "_type": "test_type", "_id": "bulk_50_refresh_id6"}} + {"index": {"_index": "bulk_50_refresh_3", "_id": "bulk_50_refresh_id6"}} {"f1": "v2", "f2": 47} - do: diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/51_refresh_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/51_refresh_with_types.yml new file mode 100644 index 0000000000000..6326b9464caa0 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/51_refresh_with_types.yml @@ -0,0 +1,48 @@ +--- +"refresh=true immediately makes changes are visible in search": + - do: + bulk: + refresh: true + body: | + {"index": {"_index": "bulk_50_refresh_1", "_type": "test_type", "_id": "bulk_50_refresh_id1"}} + {"f1": "v1", "f2": 42} + {"index": {"_index": "bulk_50_refresh_1", "_type": "test_type", "_id": "bulk_50_refresh_id2"}} + {"f1": "v2", "f2": 47} + + - do: + count: + index: bulk_50_refresh_1 + - match: {count: 2} + +--- +"refresh=empty string immediately makes changes are visible in search": + - do: + bulk: + refresh: "" + body: | + {"index": {"_index": "bulk_50_refresh_2", "_type": "test_type", "_id": "bulk_50_refresh_id3"}} + {"f1": "v1", "f2": 42} + {"index": {"_index": "bulk_50_refresh_2", "_type": "test_type", "_id": "bulk_50_refresh_id4"}} + {"f1": "v2", "f2": 47} + + - do: + count: + index: bulk_50_refresh_2 + - match: {count: 2} + + +--- +"refresh=wait_for waits until changes are visible in search": + - do: + bulk: + refresh: wait_for + body: | + {"index": {"_index": "bulk_50_refresh_3", "_type": "test_type", "_id": "bulk_50_refresh_id5"}} + {"f1": "v1", "f2": 42} + {"index": {"_index": "bulk_50_refresh_3", "_type": "test_type", "_id": "bulk_50_refresh_id6"}} + {"f1": "v2", "f2": 47} + + - do: + count: + index: bulk_50_refresh_3 + - match: {count: 2} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/10_basic.yml index a3671d5ac24b0..7f5d13125c3d4 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/10_basic.yml @@ -1,10 +1,14 @@ --- "Basic": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: index: + include_type_name: false index: test_1 - type: test id: 1 body: { foo: bar } @@ -12,8 +16,16 @@ - do: delete: + include_type_name: false index: test_1 - type: test id: 1 - match: { _version: 2 } + + - do: + catch: /illegal_argument_exception/ + delete: + include_type_name: false + index: index + type: type + id: 1 diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/11_shard_header.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/11_shard_header.yml index d1bb4c0df347d..c235b8ebfbf23 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/11_shard_header.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/11_shard_header.yml @@ -1,8 +1,13 @@ --- "Delete check shard header": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: indices.create: + include_type_name: false index: foobar body: settings: @@ -15,19 +20,19 @@ - do: index: + include_type_name: false index: foobar - type: baz id: 1 body: { foo: bar } - do: delete: + include_type_name: false index: foobar - type: baz id: 1 - match: { _index: foobar } - - match: { _type: baz } + - is_false: "_type" - match: { _id: "1"} - match: { _version: 2} - match: { _shards.total: 1} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/12_result.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/12_result.yml index d01e88be8ad0b..f6d4fffb68af8 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/12_result.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/12_result.yml @@ -1,17 +1,21 @@ --- "Delete result field": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: index: + include_type_name: false index: test_1 - type: test id: 1 body: { foo: bar } - do: delete: + include_type_name: false index: test_1 - type: test id: 1 - match: { result: deleted } @@ -19,8 +23,8 @@ - do: catch: missing delete: + include_type_name: false index: test_1 - type: test id: 1 - match: { result: not_found } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/13_basic_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/13_basic_with_types.yml new file mode 100644 index 0000000000000..a3671d5ac24b0 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/13_basic_with_types.yml @@ -0,0 +1,19 @@ +--- +"Basic": + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - match: { _version: 1 } + + - do: + delete: + index: test_1 + type: test + id: 1 + + - match: { _version: 2 } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/14_shard_header_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/14_shard_header_with_types.yml new file mode 100644 index 0000000000000..d1bb4c0df347d --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/14_shard_header_with_types.yml @@ -0,0 +1,36 @@ +--- +"Delete check shard header": + + - do: + indices.create: + index: foobar + body: + settings: + number_of_shards: "1" + number_of_replicas: "0" + + - do: + cluster.health: + wait_for_status: green + + - do: + index: + index: foobar + type: baz + id: 1 + body: { foo: bar } + + - do: + delete: + index: foobar + type: baz + id: 1 + + - match: { _index: foobar } + - match: { _type: baz } + - match: { _id: "1"} + - match: { _version: 2} + - match: { _shards.total: 1} + - match: { _shards.successful: 1} + - match: { _shards.failed: 0} + - is_false: _shards.pending diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/15_result_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/15_result_with_types.yml new file mode 100644 index 0000000000000..d01e88be8ad0b --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/15_result_with_types.yml @@ -0,0 +1,26 @@ +--- +"Delete result field": + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - do: + delete: + index: test_1 + type: test + id: 1 + + - match: { result: deleted } + + - do: + catch: missing + delete: + index: test_1 + type: test + id: 1 + + - match: { result: not_found } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/20_internal_version.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/20_internal_version.yml index 3d9ddb79366f7..c21617bcac621 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/20_internal_version.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/20_internal_version.yml @@ -1,10 +1,14 @@ --- "Internal version": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: index: + include_type_name: false index: test_1 - type: test id: 1 body: { foo: bar } @@ -13,15 +17,15 @@ - do: catch: conflict delete: + include_type_name: false index: test_1 - type: test id: 1 version: 2 - do: delete: + include_type_name: false index: test_1 - type: test id: 1 version: 1 diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/21_internal_version_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/21_internal_version_with_types.yml new file mode 100644 index 0000000000000..3d9ddb79366f7 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/21_internal_version_with_types.yml @@ -0,0 +1,28 @@ +--- +"Internal version": + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - match: { _version: 1} + + - do: + catch: conflict + delete: + index: test_1 + type: test + id: 1 + version: 2 + + - do: + delete: + index: test_1 + type: test + id: 1 + version: 1 + + - match: { _version: 2 } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/25_external_version.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/25_external_version.yml index 453d64d85bbc1..c2cae2b6e1e5d 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/25_external_version.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/25_external_version.yml @@ -1,10 +1,14 @@ --- "External version": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: index: + include_type_name: false index: test_1 - type: test id: 1 body: { foo: bar } version_type: external @@ -15,16 +19,16 @@ - do: catch: conflict delete: + include_type_name: false index: test_1 - type: test id: 1 version_type: external version: 4 - do: delete: + include_type_name: false index: test_1 - type: test id: 1 version_type: external version: 6 diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/26_external_gte_version.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/26_external_gte_version.yml index 70f78c17faa63..df119a57c12ce 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/26_external_gte_version.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/26_external_gte_version.yml @@ -1,10 +1,14 @@ --- "External GTE version": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: index: + include_type_name: false index: test_1 - type: test id: 1 body: { foo: bar } version_type: external_gte @@ -15,16 +19,16 @@ - do: catch: conflict delete: + include_type_name: false index: test_1 - type: test id: 1 version_type: external_gte version: 4 - do: delete: + include_type_name: false index: test_1 - type: test id: 1 version_type: external_gte version: 6 @@ -33,8 +37,8 @@ - do: index: + include_type_name: false index: test_1 - type: test id: 1 body: { foo: bar } version_type: external_gte @@ -44,8 +48,8 @@ - do: delete: + include_type_name: false index: test_1 - type: test id: 1 version_type: external_gte version: 6 diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/27_external_version_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/27_external_version_with_types.yml new file mode 100644 index 0000000000000..453d64d85bbc1 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/27_external_version_with_types.yml @@ -0,0 +1,32 @@ +--- +"External version": + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + version_type: external + version: 5 + + - match: { _version: 5} + + - do: + catch: conflict + delete: + index: test_1 + type: test + id: 1 + version_type: external + version: 4 + + - do: + delete: + index: test_1 + type: test + id: 1 + version_type: external + version: 6 + + - match: { _version: 6} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/28_external_gte_version_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/28_external_gte_version_with_types.yml new file mode 100644 index 0000000000000..70f78c17faa63 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/28_external_gte_version_with_types.yml @@ -0,0 +1,53 @@ +--- +"External GTE version": + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + version_type: external_gte + version: 5 + + - match: { _version: 5} + + - do: + catch: conflict + delete: + index: test_1 + type: test + id: 1 + version_type: external_gte + version: 4 + + - do: + delete: + index: test_1 + type: test + id: 1 + version_type: external_gte + version: 6 + + - match: { _version: 6} + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + version_type: external_gte + version: 6 + + - match: { _version: 6} + + - do: + delete: + index: test_1 + type: test + id: 1 + version_type: external_gte + version: 6 + + - match: { _version: 6} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/30_routing.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/30_routing.yml index 6f67b3a03f401..a0ad089b0fbe8 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/30_routing.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/30_routing.yml @@ -1,16 +1,21 @@ --- "Routing": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: indices.create: + include_type_name: false index: test_1 body: settings: number_of_shards: 5 - do: index: + include_type_name: false index: test_1 - type: test id: 1 routing: 5 body: { foo: bar } @@ -18,15 +23,15 @@ - do: catch: missing delete: + include_type_name: false index: test_1 - type: test id: 1 routing: 4 - do: delete: + include_type_name: false index: test_1 - type: test id: 1 routing: 5 diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/31_routing_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/31_routing_with_types.yml new file mode 100644 index 0000000000000..6f67b3a03f401 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/31_routing_with_types.yml @@ -0,0 +1,32 @@ +--- +"Routing": + + - do: + indices.create: + index: test_1 + body: + settings: + number_of_shards: 5 + - do: + index: + index: test_1 + type: test + id: 1 + routing: 5 + body: { foo: bar } + + - do: + catch: missing + delete: + index: test_1 + type: test + id: 1 + routing: 4 + + - do: + delete: + index: test_1 + type: test + id: 1 + routing: 5 + diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/50_refresh.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/50_refresh.yml index ad27bb68601ae..326186bf07bf3 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/50_refresh.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/50_refresh.yml @@ -1,8 +1,13 @@ --- "Refresh": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: indices.create: + include_type_name: false index: test_1 body: settings: @@ -16,8 +21,8 @@ - do: index: + include_type_name: false index: test_1 - type: test id: 1 body: { foo: bar } refresh: true @@ -27,8 +32,8 @@ # them to be different for this test to pass - do: index: + include_type_name: false index: test_1 - type: test id: 3 body: { foo: bar } refresh: true @@ -36,6 +41,7 @@ - do: search: + include_type_name: false index: test_1 body: query: { terms: { _id: [1,3] }} @@ -44,12 +50,13 @@ - do: delete: + include_type_name: false index: test_1 - type: test id: 1 - do: search: + include_type_name: false index: test_1 body: query: { terms: { _id: [1,3] }} @@ -58,8 +65,8 @@ - do: delete: + include_type_name: false index: test_1 - type: test id: 3 refresh: true @@ -69,6 +76,7 @@ - do: search: + include_type_name: false index: test_1 body: query: { terms: { _id: [1,3] }} @@ -77,10 +85,15 @@ --- "When refresh url parameter is an empty string that means \"refresh immediately\"": + + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: index: + include_type_name: false index: test_1 - type: test id: 1 body: { foo: bar } refresh: true @@ -88,6 +101,7 @@ - do: search: + include_type_name: false index: test_1 body: query: { term: { _id: 1 }} @@ -95,13 +109,14 @@ - do: delete: + include_type_name: false index: test_1 - type: test id: 1 refresh: "" - do: search: + include_type_name: false index: test_1 body: query: { term: { _id: 1 }} @@ -109,10 +124,15 @@ --- "refresh=wait_for waits until changes are visible in search": + + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: index: + include_type_name: false index: delete_50_refresh_1 - type: test id: delete_50_refresh_id1 body: { foo: bar } refresh: true @@ -120,6 +140,7 @@ - do: search: + include_type_name: false index: delete_50_refresh_1 body: query: { term: { _id: delete_50_refresh_id1 }} @@ -127,14 +148,15 @@ - do: delete: + include_type_name: false index: delete_50_refresh_1 - type: test id: delete_50_refresh_id1 refresh: wait_for - is_false: forced_refresh - do: search: + include_type_name: false index: delete_50_refresh_1 body: query: { term: { _id: delete_50_refresh_id1 }} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/51_refresh_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/51_refresh_with_types.yml new file mode 100644 index 0000000000000..ad27bb68601ae --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/51_refresh_with_types.yml @@ -0,0 +1,141 @@ +--- +"Refresh": + + - do: + indices.create: + index: test_1 + body: + settings: + refresh_interval: -1 + number_of_shards: 5 + number_of_routing_shards: 5 + number_of_replicas: 0 + - do: + cluster.health: + wait_for_status: green + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + refresh: true + +# If you wonder why this document get 3 as an id instead of 2, it is because the +# current routing algorithm would route 1 and 2 to the same shard while we need +# them to be different for this test to pass + - do: + index: + index: test_1 + type: test + id: 3 + body: { foo: bar } + refresh: true + - is_true: forced_refresh + + - do: + search: + index: test_1 + body: + query: { terms: { _id: [1,3] }} + + - match: { hits.total: 2 } + + - do: + delete: + index: test_1 + type: test + id: 1 + + - do: + search: + index: test_1 + body: + query: { terms: { _id: [1,3] }} + + - match: { hits.total: 2 } + + - do: + delete: + index: test_1 + type: test + id: 3 + refresh: true + +# If a replica shard where doc 1 is located gets initialized at this point, doc 1 +# won't be found by the following search as the shard gets automatically refreshed +# right before getting started. This is why this test only works with 0 replicas. + + - do: + search: + index: test_1 + body: + query: { terms: { _id: [1,3] }} + + - match: { hits.total: 1 } + +--- +"When refresh url parameter is an empty string that means \"refresh immediately\"": + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + refresh: true + - is_true: forced_refresh + + - do: + search: + index: test_1 + body: + query: { term: { _id: 1 }} + - match: { hits.total: 1 } + + - do: + delete: + index: test_1 + type: test + id: 1 + refresh: "" + + - do: + search: + index: test_1 + body: + query: { term: { _id: 1 }} + - match: { hits.total: 0 } + +--- +"refresh=wait_for waits until changes are visible in search": + - do: + index: + index: delete_50_refresh_1 + type: test + id: delete_50_refresh_id1 + body: { foo: bar } + refresh: true + - is_true: forced_refresh + + - do: + search: + index: delete_50_refresh_1 + body: + query: { term: { _id: delete_50_refresh_id1 }} + - match: { hits.total: 1 } + + - do: + delete: + index: delete_50_refresh_1 + type: test + id: delete_50_refresh_id1 + refresh: wait_for + - is_false: forced_refresh + + - do: + search: + index: delete_50_refresh_1 + body: + query: { term: { _id: delete_50_refresh_id1 }} + - match: { hits.total: 0 } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/60_missing.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/60_missing.yml index 9cfdb48ae20aa..46b238482d76b 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/60_missing.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/60_missing.yml @@ -1,19 +1,27 @@ --- "Missing document with catch": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: catch: missing delete: + include_type_name: false index: test_1 - type: test id: 1 --- "Missing document with ignore": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: delete: + include_type_name: false index: test_1 - type: test id: 1 ignore: 404 diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/delete/61_missing_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/61_missing_with_types.yml new file mode 100644 index 0000000000000..9cfdb48ae20aa --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/delete/61_missing_with_types.yml @@ -0,0 +1,19 @@ +--- +"Missing document with catch": + + - do: + catch: missing + delete: + index: test_1 + type: test + id: 1 + +--- +"Missing document with ignore": + + - do: + delete: + index: test_1 + type: test + id: 1 + ignore: 404 diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/10_basic.yml index 0689f714d6416..71403f0b56f78 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/get/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/get/10_basic.yml @@ -1,31 +1,32 @@ --- "Basic": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: index: + include_type_name: false index: test_1 - type: test id: 中文 body: { "foo": "Hello: 中文" } - do: get: + include_type_name: false index: test_1 - type: test id: 中文 - match: { _index: test_1 } - - match: { _type: test } + - is_false: "_type" - match: { _id: 中文 } - match: { _source: { foo: "Hello: 中文" } } - do: + catch: /illegal_argument_exception/ get: - index: test_1 - type: _all - id: 中文 - - - match: { _index: test_1 } - - match: { _type: test } - - match: { _id: 中文 } - - match: { _source: { foo: "Hello: 中文" } } + index: index + type: type + id: 1 + include_type_name: false diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/11_basic_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/11_basic_with_types.yml new file mode 100644 index 0000000000000..0689f714d6416 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/get/11_basic_with_types.yml @@ -0,0 +1,31 @@ +--- +"Basic": + + - do: + index: + index: test_1 + type: test + id: 中文 + body: { "foo": "Hello: 中文" } + + - do: + get: + index: test_1 + type: test + id: 中文 + + - match: { _index: test_1 } + - match: { _type: test } + - match: { _id: 中文 } + - match: { _source: { foo: "Hello: 中文" } } + + - do: + get: + index: test_1 + type: _all + id: 中文 + + - match: { _index: test_1 } + - match: { _type: test } + - match: { _id: 中文 } + - match: { _source: { foo: "Hello: 中文" } } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/15_default_values.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/15_default_values.yml index 5e08112253ef0..fbab99fc3c6ed 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/get/15_default_values.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/get/15_default_values.yml @@ -1,21 +1,25 @@ --- "Default values": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: index: + include_type_name: false index: test_1 - type: test id: 1 body: { "foo": "bar" } - do: get: + include_type_name: false index: test_1 - type: _all id: 1 - match: { _index: test_1 } - - match: { _type: test } + - is_false: "_type" - match: { _id: '1' } - match: { _source: { foo: "bar" } } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/16_default_values_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/16_default_values_with_types.yml new file mode 100644 index 0000000000000..5e08112253ef0 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/get/16_default_values_with_types.yml @@ -0,0 +1,21 @@ +--- +"Default values": + + - do: + index: + index: test_1 + type: test + id: 1 + body: { "foo": "bar" } + + - do: + get: + index: test_1 + type: _all + id: 1 + + - match: { _index: test_1 } + - match: { _type: test } + - match: { _id: '1' } + - match: { _source: { foo: "bar" } } + diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/20_stored_fields.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/20_stored_fields.yml index fbffb9e0ea8ce..20971728ffd96 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/get/20_stored_fields.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/get/20_stored_fields.yml @@ -1,43 +1,47 @@ --- "Stored fields": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: indices.create: + include_type_name: false index: test_1 body: mappings: - test: - properties: - foo: - type: keyword - store: true - count: - type: integer - store: true + properties: + foo: + type: keyword + store: true + count: + type: integer + store: true - do: index: + include_type_name: false index: test_1 - type: test id: 1 body: { "foo": "bar", "count": 1 } - do: get: + include_type_name: false index: test_1 - type: test id: 1 stored_fields: foo - match: { _index: test_1 } - - match: { _type: test } + - is_false: "_type" - match: { _id: '1' } - match: { fields.foo: [bar] } - is_false: _source - do: get: + include_type_name: false index: test_1 - type: test id: 1 stored_fields: [foo, count] @@ -47,8 +51,8 @@ - do: get: + include_type_name: false index: test_1 - type: test id: 1 stored_fields: [foo, count, _source] diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/21_stored_fields_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/21_stored_fields_with_types.yml new file mode 100644 index 0000000000000..fbffb9e0ea8ce --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/get/21_stored_fields_with_types.yml @@ -0,0 +1,59 @@ +--- +"Stored fields": + + - do: + indices.create: + index: test_1 + body: + mappings: + test: + properties: + foo: + type: keyword + store: true + count: + type: integer + store: true + + - do: + index: + index: test_1 + type: test + id: 1 + body: { "foo": "bar", "count": 1 } + - do: + get: + index: test_1 + type: test + id: 1 + stored_fields: foo + + - match: { _index: test_1 } + - match: { _type: test } + - match: { _id: '1' } + - match: { fields.foo: [bar] } + - is_false: _source + + - do: + get: + index: test_1 + type: test + id: 1 + stored_fields: [foo, count] + + - match: { fields.foo: [bar] } + - match: { fields.count: [1] } + - is_false: _source + + - do: + get: + index: test_1 + type: test + id: 1 + stored_fields: [foo, count, _source] + + - match: { fields.foo: [bar] } + - match: { fields.count: [1] } + - match: { _source.foo: bar } + + diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/40_routing.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/40_routing.yml index 276346cda4f98..941623142259b 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/get/40_routing.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/get/40_routing.yml @@ -1,8 +1,13 @@ --- "Routing": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: indices.create: + include_type_name: false index: test_1 body: settings: @@ -17,16 +22,16 @@ - do: index: + include_type_name: false index: test_1 - type: test id: 1 routing: 5 body: { foo: bar } - do: get: + include_type_name: false index: test_1 - type: test id: 1 routing: 5 stored_fields: [_routing] @@ -37,7 +42,7 @@ - do: catch: missing get: + include_type_name: false index: test_1 - type: test id: 1 diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/41_routing_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/41_routing_with_types.yml new file mode 100644 index 0000000000000..276346cda4f98 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/get/41_routing_with_types.yml @@ -0,0 +1,43 @@ +--- +"Routing": + + - do: + indices.create: + index: test_1 + body: + settings: + index: + number_of_shards: 5 + number_of_routing_shards: 5 + number_of_replicas: 0 + + - do: + cluster.health: + wait_for_status: green + + - do: + index: + index: test_1 + type: test + id: 1 + routing: 5 + body: { foo: bar } + + - do: + get: + index: test_1 + type: test + id: 1 + routing: 5 + stored_fields: [_routing] + + - match: { _id: "1"} + - match: { _routing: "5"} + + - do: + catch: missing + get: + index: test_1 + type: test + id: 1 + diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/50_with_headers.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/50_with_headers.yml index b88dbaafc4fb2..bd26eee1b5dd2 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/get/50_with_headers.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/get/50_with_headers.yml @@ -2,11 +2,13 @@ "REST test with headers": - skip: features: ["headers", "yaml"] + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 - do: index: + include_type_name: false index: test_1 - type: test id: 1 body: { "body": "foo" } @@ -14,12 +16,12 @@ headers: Accept: application/yaml get: + include_type_name: false index: test_1 - type: _all id: 1 - match: {_index: "test_1"} - - match: {_type: "test"} + - is_false: "_type" - match: {_id: "1"} - match: {_version: 1} - match: {found: true} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/51_with_headers_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/51_with_headers_with_types.yml new file mode 100644 index 0000000000000..b88dbaafc4fb2 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/get/51_with_headers_with_types.yml @@ -0,0 +1,26 @@ +--- +"REST test with headers": + - skip: + features: ["headers", "yaml"] + + - do: + index: + index: test_1 + type: test + id: 1 + body: { "body": "foo" } + + - do: + headers: + Accept: application/yaml + get: + index: test_1 + type: _all + id: 1 + + - match: {_index: "test_1"} + - match: {_type: "test"} + - match: {_id: "1"} + - match: {_version: 1} + - match: {found: true} + - match: { _source: { body: foo }} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/60_realtime_refresh.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/60_realtime_refresh.yml index 7d02b4667efe7..c5955bf4d7a70 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/get/60_realtime_refresh.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/get/60_realtime_refresh.yml @@ -1,8 +1,13 @@ --- "Realtime Refresh": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: indices.create: + include_type_name: false index: test_1 body: settings: @@ -16,23 +21,23 @@ - do: index: + include_type_name: false index: test_1 - type: test id: 1 body: { foo: bar } - do: catch: missing get: + include_type_name: false index: test_1 - type: test id: 1 realtime: false - do: get: + include_type_name: false index: test_1 - type: test id: 1 realtime: true @@ -40,8 +45,8 @@ - do: get: + include_type_name: false index: test_1 - type: test id: 1 realtime: false refresh: true diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/61_realtime_refresh_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/61_realtime_refresh_with_types.yml new file mode 100644 index 0000000000000..7d02b4667efe7 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/get/61_realtime_refresh_with_types.yml @@ -0,0 +1,49 @@ +--- +"Realtime Refresh": + + - do: + indices.create: + index: test_1 + body: + settings: + index: + refresh_interval: -1 + number_of_replicas: 0 + + - do: + cluster.health: + wait_for_status: green + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - do: + catch: missing + get: + index: test_1 + type: test + id: 1 + realtime: false + + - do: + get: + index: test_1 + type: test + id: 1 + realtime: true + + - is_true: found + + - do: + get: + index: test_1 + type: test + id: 1 + realtime: false + refresh: true + + - is_true: found diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/70_source_filtering.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/70_source_filtering.yml index c858886ca3df3..55520000e2f83 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/get/70_source_filtering.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/get/70_source_filtering.yml @@ -1,53 +1,57 @@ --- "Source filtering": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: indices.create: + include_type_name: false index: test_1 body: mappings: - test: - properties: - count: - type: integer - store: true + properties: + count: + type: integer + store: true - do: index: + include_type_name: false index: test_1 - type: test id: 1 body: { "include": { "field1": "v1", "field2": "v2" }, "count": 1 } - do: - get: { index: test_1, type: test, id: 1, _source: false } + get: { include_type_name: false, index: test_1, id: 1, _source: false } - match: { _index: test_1 } - - match: { _type: test } + - is_false: "_type" - match: { _id: "1" } - is_false: _source - do: - get: { index: test_1, type: test, id: 1, _source: true } + get: { include_type_name: false, index: test_1, id: 1, _source: true } - match: { _source.include.field1: v1 } - do: - get: { index: test_1, type: test, id: 1, _source: include.field1 } + get: { include_type_name: false, index: test_1, id: 1, _source: include.field1 } - match: { _source.include.field1: v1 } - is_false: _source.include.field2 - do: - get: { index: test_1, type: test, id: 1, _source_include: include.field1 } + get: { include_type_name: false, index: test_1, id: 1, _source_include: include.field1 } - match: { _source.include.field1: v1 } - is_false: _source.include.field2 - do: - get: { index: test_1, type: test, id: 1, _source_include: "include.field1,include.field2" } + get: { include_type_name: false, index: test_1, id: 1, _source_include: "include.field1,include.field2" } - match: { _source.include.field1: v1 } - match: { _source.include.field2: v2 } - is_false: _source.count - do: - get: { index: test_1, type: test, id: 1, _source_include: include, _source_exclude: "*.field2" } + get: { include_type_name: false, index: test_1, id: 1, _source_include: include, _source_exclude: "*.field2" } - match: { _source.include.field1: v1 } - is_false: _source.include.field2 - is_false: _source.count @@ -55,14 +59,14 @@ - do: get: + include_type_name: false index: test_1 - type: test id: 1 stored_fields: count _source: true - match: { _index: test_1 } - - match: { _type: test } + - is_false: "_type" - match: { _id: "1" } - match: { fields.count: [1] } - match: { _source.include.field1: v1 } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/71_source_filtering_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/71_source_filtering_with_types.yml new file mode 100644 index 0000000000000..c858886ca3df3 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/get/71_source_filtering_with_types.yml @@ -0,0 +1,68 @@ +--- +"Source filtering": + + - do: + indices.create: + index: test_1 + body: + mappings: + test: + properties: + count: + type: integer + store: true + + - do: + index: + index: test_1 + type: test + id: 1 + body: { "include": { "field1": "v1", "field2": "v2" }, "count": 1 } + - do: + get: { index: test_1, type: test, id: 1, _source: false } + + - match: { _index: test_1 } + - match: { _type: test } + - match: { _id: "1" } + - is_false: _source + + - do: + get: { index: test_1, type: test, id: 1, _source: true } + - match: { _source.include.field1: v1 } + + - do: + get: { index: test_1, type: test, id: 1, _source: include.field1 } + - match: { _source.include.field1: v1 } + - is_false: _source.include.field2 + + - do: + get: { index: test_1, type: test, id: 1, _source_include: include.field1 } + - match: { _source.include.field1: v1 } + - is_false: _source.include.field2 + + - do: + get: { index: test_1, type: test, id: 1, _source_include: "include.field1,include.field2" } + - match: { _source.include.field1: v1 } + - match: { _source.include.field2: v2 } + - is_false: _source.count + + - do: + get: { index: test_1, type: test, id: 1, _source_include: include, _source_exclude: "*.field2" } + - match: { _source.include.field1: v1 } + - is_false: _source.include.field2 + - is_false: _source.count + + + - do: + get: + index: test_1 + type: test + id: 1 + stored_fields: count + _source: true + + - match: { _index: test_1 } + - match: { _type: test } + - match: { _id: "1" } + - match: { fields.count: [1] } + - match: { _source.include.field1: v1 } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/80_missing.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/80_missing.yml index a60d11388566d..48a6966b455b0 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/get/80_missing.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/get/80_missing.yml @@ -1,19 +1,27 @@ --- "Missing document with catch": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: catch: missing get: + include_type_name: false index: test_1 - type: test id: 1 --- "Missing document with ignore": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: get: + include_type_name: false index: test_1 - type: test id: 1 ignore: 404 diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/81_missing_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/81_missing_with_types.yml new file mode 100644 index 0000000000000..a60d11388566d --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/get/81_missing_with_types.yml @@ -0,0 +1,19 @@ +--- +"Missing document with catch": + + - do: + catch: missing + get: + index: test_1 + type: test + id: 1 + +--- +"Missing document with ignore": + + - do: + get: + index: test_1 + type: test + id: 1 + ignore: 404 diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/90_versions.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/90_versions.yml index c6631b83b1867..6975d4f5be518 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/get/90_versions.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/get/90_versions.yml @@ -1,26 +1,30 @@ --- "Versions": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: index: + include_type_name: false index: test_1 - type: test id: 1 body: { foo: bar } - match: { _version: 1} - do: index: + include_type_name: false index: test_1 - type: test id: 1 body: { foo: bar } - match: { _version: 2} - do: get: + include_type_name: false index: test_1 - type: test id: 1 version: 2 - match: { _id: "1" } @@ -28,15 +32,15 @@ - do: catch: conflict get: + include_type_name: false index: test_1 - type: test id: 1 version: 1 - do: get: + include_type_name: false index: test_1 - type: test id: 1 version: 2 version_type: external @@ -45,8 +49,8 @@ - do: catch: conflict get: + include_type_name: false index: test_1 - type: test id: 1 version: 10 version_type: external @@ -54,16 +58,16 @@ - do: catch: conflict get: + include_type_name: false index: test_1 - type: test id: 1 version: 1 version_type: external - do: get: + include_type_name: false index: test_1 - type: test id: 1 version: 2 version_type: external_gte @@ -72,8 +76,8 @@ - do: catch: conflict get: + include_type_name: false index: test_1 - type: test id: 1 version: 10 version_type: external_gte @@ -81,8 +85,8 @@ - do: catch: conflict get: + include_type_name: false index: test_1 - type: test id: 1 version: 1 version_type: external_gte diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/get/91_versions_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/get/91_versions_with_types.yml new file mode 100644 index 0000000000000..c6631b83b1867 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/get/91_versions_with_types.yml @@ -0,0 +1,89 @@ +--- +"Versions": + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + - match: { _version: 1} + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + - match: { _version: 2} + + - do: + get: + index: test_1 + type: test + id: 1 + version: 2 + - match: { _id: "1" } + + - do: + catch: conflict + get: + index: test_1 + type: test + id: 1 + version: 1 + + - do: + get: + index: test_1 + type: test + id: 1 + version: 2 + version_type: external + - match: { _id: "1" } + + - do: + catch: conflict + get: + index: test_1 + type: test + id: 1 + version: 10 + version_type: external + + - do: + catch: conflict + get: + index: test_1 + type: test + id: 1 + version: 1 + version_type: external + + - do: + get: + index: test_1 + type: test + id: 1 + version: 2 + version_type: external_gte + - match: { _id: "1" } + + - do: + catch: conflict + get: + index: test_1 + type: test + id: 1 + version: 10 + version_type: external_gte + + - do: + catch: conflict + get: + index: test_1 + type: test + id: 1 + version: 1 + version_type: external_gte + diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/10_with_id.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/10_with_id.yml index daac81849fb5e..0deb76376945b 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/index/10_with_id.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/index/10_with_id.yml @@ -1,26 +1,30 @@ --- "Index with ID": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: index: + include_type_name: false index: test-weird-index-中文 - type: weird.type id: 1 body: { foo: bar } - match: { _index: test-weird-index-中文 } - - match: { _type: weird.type } + - is_false: "_type" - match: { _id: "1"} - match: { _version: 1} - do: get: + include_type_name: false index: test-weird-index-中文 - type: weird.type id: 1 - match: { _index: test-weird-index-中文 } - - match: { _type: weird.type } + - is_false: "_type" - match: { _id: "1"} - match: { _version: 1} - match: { _source: { foo: bar }} @@ -28,7 +32,16 @@ - do: catch: bad_request index: + include_type_name: false index: idx - type: type id: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa body: { foo: bar } + + - do: + catch: /illegal_argument_exception/ + index: + index: index + type: type + id: 1 + include_type_name: false + body: { foo: bar } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/11_with_id_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/11_with_id_with_types.yml new file mode 100644 index 0000000000000..daac81849fb5e --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/index/11_with_id_with_types.yml @@ -0,0 +1,34 @@ +--- +"Index with ID": + + - do: + index: + index: test-weird-index-中文 + type: weird.type + id: 1 + body: { foo: bar } + + - match: { _index: test-weird-index-中文 } + - match: { _type: weird.type } + - match: { _id: "1"} + - match: { _version: 1} + + - do: + get: + index: test-weird-index-中文 + type: weird.type + id: 1 + + - match: { _index: test-weird-index-中文 } + - match: { _type: weird.type } + - match: { _id: "1"} + - match: { _version: 1} + - match: { _source: { foo: bar }} + + - do: + catch: bad_request + index: + index: idx + type: type + id: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + body: { foo: bar } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/12_result.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/12_result.yml index 45ebe0bbd3dc1..7198c694b511a 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/index/12_result.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/index/12_result.yml @@ -1,10 +1,14 @@ --- "Index result field": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: index: + include_type_name: false index: test_index - type: test id: 1 body: { foo: bar } @@ -12,8 +16,8 @@ - do: index: + include_type_name: false index: test_index - type: test id: 1 body: { foo: bar } op_type: index diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/13_result_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/13_result_with_types.yml new file mode 100644 index 0000000000000..45ebe0bbd3dc1 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/index/13_result_with_types.yml @@ -0,0 +1,21 @@ +--- +"Index result field": + + - do: + index: + index: test_index + type: test + id: 1 + body: { foo: bar } + + - match: { result: created } + + - do: + index: + index: test_index + type: test + id: 1 + body: { foo: bar } + op_type: index + + - match: { result: updated } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/15_without_id.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/15_without_id.yml index 3fff0512b9602..3bd607c66fac7 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/index/15_without_id.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/index/15_without_id.yml @@ -1,26 +1,38 @@ --- "Index without ID": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: index: + include_type_name: false index: test_1 - type: test body: { foo: bar } - is_true: _id - match: { _index: test_1 } - - match: { _type: test } + - is_false: "_type" - match: { _version: 1 } - set: { _id: id } - do: get: + include_type_name: false index: test_1 - type: test id: '$id' - match: { _index: test_1 } - - match: { _type: test } + - is_false: "_type" - match: { _id: $id } - match: { _version: 1 } - match: { _source: { foo: bar }} + + - do: + catch: /illegal_argument_exception/ + index: + index: index + type: type + include_type_name: false + body: { foo: bar } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/16_without_id_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/16_without_id_with_types.yml new file mode 100644 index 0000000000000..3fff0512b9602 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/index/16_without_id_with_types.yml @@ -0,0 +1,26 @@ +--- +"Index without ID": + + - do: + index: + index: test_1 + type: test + body: { foo: bar } + + - is_true: _id + - match: { _index: test_1 } + - match: { _type: test } + - match: { _version: 1 } + - set: { _id: id } + + - do: + get: + index: test_1 + type: test + id: '$id' + + - match: { _index: test_1 } + - match: { _type: test } + - match: { _id: $id } + - match: { _version: 1 } + - match: { _source: { foo: bar }} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/20_optype.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/20_optype.yml index 60ae26d46d07d..ddab362b80f9f 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/index/20_optype.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/index/20_optype.yml @@ -1,10 +1,14 @@ --- "Optype": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: index: + include_type_name: false index: test_1 - type: test id: 1 op_type: create body: { foo: bar } @@ -12,16 +16,16 @@ - do: catch: conflict index: + include_type_name: false index: test_1 - type: test id: 1 op_type: create body: { foo: bar } - do: index: + include_type_name: false index: test_1 - type: test id: 1 op_type: index body: { foo: bar } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/21_optype_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/21_optype_with_types.yml new file mode 100644 index 0000000000000..60ae26d46d07d --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/index/21_optype_with_types.yml @@ -0,0 +1,29 @@ +--- +"Optype": + + - do: + index: + index: test_1 + type: test + id: 1 + op_type: create + body: { foo: bar } + + - do: + catch: conflict + index: + index: test_1 + type: test + id: 1 + op_type: create + body: { foo: bar } + + - do: + index: + index: test_1 + type: test + id: 1 + op_type: index + body: { foo: bar } + + - match: { _version: 2 } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/30_internal_version.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/30_internal_version.yml index 1767fbebbf966..53351c24feb35 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/index/30_internal_version.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/index/30_internal_version.yml @@ -1,18 +1,22 @@ --- "Internal version": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: index: + include_type_name: false index: test_1 - type: test id: 1 body: { foo: bar } - match: { _version: 1} - do: index: + include_type_name: false index: test_1 - type: test id: 1 body: { foo: bar } - match: { _version: 2} @@ -20,15 +24,15 @@ - do: catch: conflict index: + include_type_name: false index: test_1 - type: test id: 1 body: { foo: bar } version: 1 - do: index: + include_type_name: false index: test_1 - type: test id: 1 body: { foo: bar } version: 2 diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/31_internal_version_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/31_internal_version_with_types.yml new file mode 100644 index 0000000000000..1767fbebbf966 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/index/31_internal_version_with_types.yml @@ -0,0 +1,36 @@ +--- +"Internal version": + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + - match: { _version: 1} + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + - match: { _version: 2} + + - do: + catch: conflict + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + version: 1 + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + version: 2 + + - match: { _version: 3 } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/35_external_version.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/35_external_version.yml index f17e6b749319d..054f8cad15ddf 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/index/35_external_version.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/index/35_external_version.yml @@ -1,10 +1,14 @@ --- "External version": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: index: + include_type_name: false index: test_1 - type: test id: 1 body: { foo: bar } version_type: external @@ -14,8 +18,8 @@ - do: index: + include_type_name: false index: test_1 - type: test id: 1 body: { foo: bar } version_type: external @@ -26,8 +30,8 @@ - do: catch: conflict index: + include_type_name: false index: test_1 - type: test id: 1 body: { foo: bar } version_type: external @@ -36,8 +40,8 @@ - do: catch: conflict index: + include_type_name: false index: test_1 - type: test id: 1 body: { foo: bar } version_type: external @@ -45,8 +49,8 @@ - do: index: + include_type_name: false index: test_1 - type: test id: 1 body: { foo: bar } version_type: external diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/36_external_gte_version.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/36_external_gte_version.yml index dccbe02ea1400..67f534db341df 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/index/36_external_gte_version.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/index/36_external_gte_version.yml @@ -1,10 +1,14 @@ --- "External GTE version": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: index: + include_type_name: false index: test_1 - type: test id: 1 body: { foo: bar } version_type: external_gte @@ -14,8 +18,8 @@ - do: index: + include_type_name: false index: test_1 - type: test id: 1 body: { foo: bar } version_type: external_gte @@ -26,8 +30,8 @@ - do: catch: conflict index: + include_type_name: false index: test_1 - type: test id: 1 body: { foo: bar } version_type: external_gte @@ -35,8 +39,8 @@ - do: index: + include_type_name: false index: test_1 - type: test id: 1 body: { foo: bar2 } version_type: external_gte @@ -46,8 +50,8 @@ - do: index: + include_type_name: false index: test_1 - type: test id: 1 body: { foo: bar2 } version_type: external_gte diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/37_external_version_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/37_external_version_with_types.yml new file mode 100644 index 0000000000000..f17e6b749319d --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/index/37_external_version_with_types.yml @@ -0,0 +1,55 @@ +--- +"External version": + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + version_type: external + version: 0 + + - match: { _version: 0 } + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + version_type: external + version: 5 + + - match: { _version: 5 } + + - do: + catch: conflict + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + version_type: external + version: 5 + + - do: + catch: conflict + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + version_type: external + version: 0 + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + version_type: external + version: 6 + + - match: { _version: 6} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/38_external_gte_version_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/38_external_gte_version_with_types.yml new file mode 100644 index 0000000000000..dccbe02ea1400 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/index/38_external_gte_version_with_types.yml @@ -0,0 +1,56 @@ +--- +"External GTE version": + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + version_type: external_gte + version: 0 + + - match: { _version: 0} + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + version_type: external_gte + version: 5 + + - match: { _version: 5} + + - do: + catch: conflict + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + version_type: external_gte + version: 0 + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar2 } + version_type: external_gte + version: 5 + + - match: { _version: 5} + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar2 } + version_type: external_gte + version: 6 + + - match: { _version: 6} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/40_routing.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/40_routing.yml index 5b0cf94f4236b..523cf47f8582d 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/index/40_routing.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/index/40_routing.yml @@ -1,8 +1,13 @@ --- "Routing": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: indices.create: + include_type_name: false index: test_1 body: settings: @@ -17,16 +22,16 @@ - do: index: + include_type_name: false index: test_1 - type: test id: 1 routing: 5 body: { foo: bar } - do: get: + include_type_name: false index: test_1 - type: test id: 1 routing: 5 stored_fields: [_routing] @@ -37,7 +42,7 @@ - do: catch: missing get: + include_type_name: false index: test_1 - type: test id: 1 diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/41_routing_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/41_routing_with_types.yml new file mode 100644 index 0000000000000..5b0cf94f4236b --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/index/41_routing_with_types.yml @@ -0,0 +1,43 @@ +--- +"Routing": + + - do: + indices.create: + index: test_1 + body: + settings: + index: + number_of_shards: 5 + number_of_routing_shards: 5 + number_of_replicas: 0 + + - do: + cluster.health: + wait_for_status: green + + - do: + index: + index: test_1 + type: test + id: 1 + routing: 5 + body: { foo: bar } + + - do: + get: + index: test_1 + type: test + id: 1 + routing: 5 + stored_fields: [_routing] + + - match: { _id: "1"} + - match: { _routing: "5"} + + - do: + catch: missing + get: + index: test_1 + type: test + id: 1 + diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/60_refresh.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/60_refresh.yml index cd78a4e4282fe..346338791d61c 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/index/60_refresh.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/index/60_refresh.yml @@ -1,8 +1,13 @@ --- "Refresh": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: indices.create: + include_type_name: false index: test_1 body: settings: @@ -11,13 +16,14 @@ - do: index: + include_type_name: false index: test_1 - type: test id: 1 body: { foo: bar } - do: search: + include_type_name: false index: test_1 body: query: { term: { _id: 1 }} @@ -26,8 +32,8 @@ - do: index: + include_type_name: false index: test_1 - type: test id: 2 refresh: true body: { foo: bar } @@ -35,6 +41,7 @@ - do: search: + include_type_name: false index: test_1 body: query: { term: { _id: 2 }} @@ -43,10 +50,15 @@ --- "When refresh url parameter is an empty string that means \"refresh immediately\"": + + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: index: + include_type_name: false index: test_1 - type: test id: 1 refresh: "" body: { foo: bar } @@ -54,6 +66,7 @@ - do: search: + include_type_name: false index: test_1 body: query: { term: { _id: 1 }} @@ -62,10 +75,15 @@ --- "refresh=wait_for waits until changes are visible in search": + + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: index: + include_type_name: false index: index_60_refresh_1 - type: test id: index_60_refresh_id1 body: { foo: bar } refresh: wait_for @@ -73,6 +91,7 @@ - do: search: + include_type_name: false index: index_60_refresh_1 body: query: { term: { _id: index_60_refresh_id1 }} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/index/61_refresh_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/index/61_refresh_with_types.yml new file mode 100644 index 0000000000000..cd78a4e4282fe --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/index/61_refresh_with_types.yml @@ -0,0 +1,79 @@ +--- +"Refresh": + + - do: + indices.create: + index: test_1 + body: + settings: + index.refresh_interval: -1 + number_of_replicas: 0 + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - do: + search: + index: test_1 + body: + query: { term: { _id: 1 }} + + - match: { hits.total: 0 } + + - do: + index: + index: test_1 + type: test + id: 2 + refresh: true + body: { foo: bar } + - is_true: forced_refresh + + - do: + search: + index: test_1 + body: + query: { term: { _id: 2 }} + + - match: { hits.total: 1 } + +--- +"When refresh url parameter is an empty string that means \"refresh immediately\"": + - do: + index: + index: test_1 + type: test + id: 1 + refresh: "" + body: { foo: bar } + - is_true: forced_refresh + + - do: + search: + index: test_1 + body: + query: { term: { _id: 1 }} + + - match: { hits.total: 1 } + +--- +"refresh=wait_for waits until changes are visible in search": + - do: + index: + index: index_60_refresh_1 + type: test + id: index_60_refresh_id1 + body: { foo: bar } + refresh: wait_for + - is_false: forced_refresh + + - do: + search: + index: index_60_refresh_1 + body: + query: { term: { _id: index_60_refresh_id1 }} + - match: { hits.total: 1 } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.create/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.create/10_basic.yml index 6f7c5a6009386..a96c31e9ce6ab 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.create/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.create/10_basic.yml @@ -1,24 +1,35 @@ --- "Create index with mappings": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: indices.create: + include_type_name: false index: test_index body: mappings: - type_1: {} + {} - do: indices.get_mapping: + include_type_name: false index: test_index - - is_true: test_index.mappings.type_1 + - is_true: test_index.mappings --- "Create index with settings": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: indices.create: + include_type_name: false index: test_index body: settings: @@ -33,8 +44,13 @@ --- "Create index": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: indices.create: + include_type_name: false index: test_index - match: { acknowledged: true } @@ -43,8 +59,13 @@ --- "Create index with wait_for_active_shards set to all": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: indices.create: + include_type_name: false index: test_index wait_for_active_shards: all body: @@ -57,15 +78,19 @@ --- "Create index with aliases": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: indices.create: + include_type_name: false index: test_index body: mappings: - type_1: - properties: - field: - type: text + properties: + field: + type: text aliases: test_alias: {} test_blias: @@ -93,6 +118,7 @@ reason: is_write_index is not implemented in ES <= 6.x - do: indices.create: + include_type_name: false index: test_index body: aliases: @@ -110,25 +136,15 @@ - is_false: test_index.aliases.test_blias.is_write_index - is_true: test_index.aliases.test_clias.is_write_index ---- -"Create index with no type mappings": - - do: - catch: /illegal_argument_exception/ - indices.create: - index: test_index - body: - mappings: - "" : {} - --- "Create index with invalid mappings": - do: catch: /illegal_argument_exception/ indices.create: + include_type_name: false index: test_index body: mappings: - test_type: - properties: - "": - type: keyword + properties: + "": + type: keyword diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.create/11_basic_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.create/11_basic_with_types.yml new file mode 100644 index 0000000000000..6f7c5a6009386 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.create/11_basic_with_types.yml @@ -0,0 +1,134 @@ +--- +"Create index with mappings": + + - do: + indices.create: + index: test_index + body: + mappings: + type_1: {} + + - do: + indices.get_mapping: + index: test_index + + - is_true: test_index.mappings.type_1 + +--- +"Create index with settings": + + - do: + indices.create: + index: test_index + body: + settings: + number_of_replicas: "0" + + - do: + indices.get_settings: + index: test_index + + - match: { test_index.settings.index.number_of_replicas: "0"} + +--- +"Create index": + + - do: + indices.create: + index: test_index + + - match: { acknowledged: true } + - match: { index: "test_index"} + +--- +"Create index with wait_for_active_shards set to all": + + - do: + indices.create: + index: test_index + wait_for_active_shards: all + body: + settings: + number_of_replicas: "0" + + - match: { acknowledged: true } + - match: { shards_acknowledged: true } + +--- +"Create index with aliases": + + - do: + indices.create: + index: test_index + body: + mappings: + type_1: + properties: + field: + type: text + aliases: + test_alias: {} + test_blias: + routing: b + test_clias: + filter: + term: + field : value + + - do: + indices.get_alias: + index: test_index + + - match: {test_index.aliases.test_blias.search_routing: b} + - match: {test_index.aliases.test_blias.index_routing: b} + - is_false: test_index.aliases.test_blias.filter + - match: {test_index.aliases.test_clias.filter.term.field: value} + - is_false: test_index.aliases.test_clias.index_routing + - is_false: test_index.aliases.test_clias.search_routing + +--- +"Create index with write aliases": + - skip: + version: " - 6.99.99" + reason: is_write_index is not implemented in ES <= 6.x + - do: + indices.create: + index: test_index + body: + aliases: + test_alias: {} + test_blias: + is_write_index: false + test_clias: + is_write_index: true + + - do: + indices.get_alias: + index: test_index + + - is_false: test_index.aliases.test_alias.is_write_index + - is_false: test_index.aliases.test_blias.is_write_index + - is_true: test_index.aliases.test_clias.is_write_index + +--- +"Create index with no type mappings": + - do: + catch: /illegal_argument_exception/ + indices.create: + index: test_index + body: + mappings: + "" : {} + +--- +"Create index with invalid mappings": + - do: + catch: /illegal_argument_exception/ + indices.create: + index: test_index + body: + mappings: + test_type: + properties: + "": + type: keyword diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/10_basic.yml index 90bb2747a7bfc..36f45dd0e6018 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/10_basic.yml @@ -1,26 +1,32 @@ --- setup: + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: indices.create: + include_type_name: false index: test_1 body: - mappings: - doc: {} + mappings: {} - do: indices.create: + include_type_name: false index: test_2 body: - mappings: - doc: {} + mappings: {} --- "Get /{index}/_mapping with empty mappings": - do: indices.create: + include_type_name: false index: t - do: indices.get_mapping: + include_type_name: false index: t - match: { t.mappings: {}} @@ -28,117 +34,66 @@ setup: --- "Get /_mapping": - - do: - indices.get_mapping: {} - - - is_true: test_1.mappings.doc - - is_true: test_2.mappings.doc - ---- -"Get /{index}/_mapping": - - - do: - indices.get_mapping: - index: test_1 - - - is_true: test_1.mappings.doc - - is_false: test_2 - - ---- -"Get /{index}/_mapping/_all": - - do: indices.get_mapping: - index: test_1 - type: _all + include_type_name: false - - is_true: test_1.mappings.doc - - is_false: test_2 + - is_true: test_1.mappings + - is_true: test_2.mappings --- -"Get /{index}/_mapping/*": - - - do: - indices.get_mapping: - index: test_1 - type: '*' - - - is_true: test_1.mappings.doc - - is_false: test_2 - ---- -"Get /{index}/_mapping/{type}": - - - do: - indices.get_mapping: - index: test_1 - type: doc - - - is_true: test_1.mappings.doc - - is_false: test_2 - ---- -"Get /{index}/_mapping/{type*}": +"Get /{index}/_mapping": - do: indices.get_mapping: - index: test_1 - type: 'd*' + include_type_name: false + index: test_1 - - is_true: test_1.mappings.doc + - is_true: test_1.mappings - is_false: test_2 ---- -"Get /_mapping/{type}": - - - do: - indices.get_mapping: - type: doc - - is_true: test_1.mappings.doc - - is_true: test_2.mappings.doc --- -"Get /_all/_mapping/{type}": +"Get /_all/_mapping": - do: indices.get_mapping: - index: _all - type: doc + include_type_name: false + index: _all - - is_true: test_1.mappings.doc - - is_true: test_2.mappings.doc + - is_true: test_1.mappings + - is_true: test_2.mappings --- -"Get /*/_mapping/{type}": +"Get /*/_mapping": - do: indices.get_mapping: - index: '*' - type: doc + include_type_name: false + index: '*' - - is_true: test_1.mappings.doc - - is_true: test_2.mappings.doc + - is_true: test_1.mappings + - is_true: test_2.mappings --- -"Get /index,index/_mapping/{type}": +"Get /index,index/_mapping": - do: indices.get_mapping: - index: test_1,test_2 - type: doc + include_type_name: false + index: test_1,test_2 - - is_true: test_1.mappings.doc - - is_true: test_2.mappings.doc + - is_true: test_1.mappings + - is_true: test_2.mappings --- -"Get /index*/_mapping/{type}": +"Get /index*/_mapping/": - do: indices.get_mapping: - index: '*2' - type: doc + include_type_name: false + index: '*2' - - is_true: test_2.mappings.doc + - is_true: test_2.mappings - is_false: test_1 diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/11_basic_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/11_basic_with_types.yml new file mode 100644 index 0000000000000..90bb2747a7bfc --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/11_basic_with_types.yml @@ -0,0 +1,144 @@ +--- +setup: + - do: + indices.create: + index: test_1 + body: + mappings: + doc: {} + - do: + indices.create: + index: test_2 + body: + mappings: + doc: {} +--- +"Get /{index}/_mapping with empty mappings": + + - do: + indices.create: + index: t + + - do: + indices.get_mapping: + index: t + + - match: { t.mappings: {}} + +--- +"Get /_mapping": + + - do: + indices.get_mapping: {} + + - is_true: test_1.mappings.doc + - is_true: test_2.mappings.doc + +--- +"Get /{index}/_mapping": + + - do: + indices.get_mapping: + index: test_1 + + - is_true: test_1.mappings.doc + - is_false: test_2 + + +--- +"Get /{index}/_mapping/_all": + + - do: + indices.get_mapping: + index: test_1 + type: _all + + - is_true: test_1.mappings.doc + - is_false: test_2 + +--- +"Get /{index}/_mapping/*": + + - do: + indices.get_mapping: + index: test_1 + type: '*' + + - is_true: test_1.mappings.doc + - is_false: test_2 + +--- +"Get /{index}/_mapping/{type}": + + - do: + indices.get_mapping: + index: test_1 + type: doc + + - is_true: test_1.mappings.doc + - is_false: test_2 + +--- +"Get /{index}/_mapping/{type*}": + + - do: + indices.get_mapping: + index: test_1 + type: 'd*' + + - is_true: test_1.mappings.doc + - is_false: test_2 + +--- +"Get /_mapping/{type}": + + - do: + indices.get_mapping: + type: doc + + - is_true: test_1.mappings.doc + - is_true: test_2.mappings.doc + +--- +"Get /_all/_mapping/{type}": + + - do: + indices.get_mapping: + index: _all + type: doc + + - is_true: test_1.mappings.doc + - is_true: test_2.mappings.doc + +--- +"Get /*/_mapping/{type}": + + - do: + indices.get_mapping: + index: '*' + type: doc + + - is_true: test_1.mappings.doc + - is_true: test_2.mappings.doc + +--- +"Get /index,index/_mapping/{type}": + + - do: + indices.get_mapping: + index: test_1,test_2 + type: doc + + - is_true: test_1.mappings.doc + - is_true: test_2.mappings.doc + +--- +"Get /index*/_mapping/{type}": + + - do: + indices.get_mapping: + index: '*2' + type: doc + + - is_true: test_2.mappings.doc + - is_false: test_1 diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/10_basic.yml index 1d33f2d31bb15..7588c66188546 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/10_basic.yml @@ -1,69 +1,104 @@ --- "Test Create and update mapping": + + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: indices.create: + include_type_name: false index: test_index - do: indices.put_mapping: + include_type_name: false index: test_index - type: test_type body: - test_type: - properties: - text1: - type: text - analyzer: whitespace - text2: - type: text - analyzer: whitespace - subfield.text3: - type: text + properties: + text1: + type: text + analyzer: whitespace + text2: + type: text + analyzer: whitespace + subfield.text3: + type: text - do: indices.get_mapping: + include_type_name: false index: test_index - - match: {test_index.mappings.test_type.properties.text1.type: text} - - match: {test_index.mappings.test_type.properties.text1.analyzer: whitespace} - - match: {test_index.mappings.test_type.properties.text2.type: text} - - match: {test_index.mappings.test_type.properties.text2.analyzer: whitespace} + - match: {test_index.mappings.properties.text1.type: text} + - match: {test_index.mappings.properties.text1.analyzer: whitespace} + - match: {test_index.mappings.properties.text2.type: text} + - match: {test_index.mappings.properties.text2.analyzer: whitespace} - do: indices.put_mapping: + include_type_name: false index: test_index - type: test_type body: - test_type: - properties: - text1: - type: text - analyzer: whitespace - fields: - text_raw: - type: keyword + properties: + text1: + type: text + analyzer: whitespace + fields: + text_raw: + type: keyword - do: indices.get_mapping: + include_type_name: false index: test_index - - match: {test_index.mappings.test_type.properties.text1.type: text} - - match: {test_index.mappings.test_type.properties.subfield.properties.text3.type: text} - - match: {test_index.mappings.test_type.properties.text1.fields.text_raw.type: keyword} + - match: {test_index.mappings.properties.text1.type: text} + - match: {test_index.mappings.properties.subfield.properties.text3.type: text} + - match: {test_index.mappings.properties.text1.fields.text_raw.type: keyword} --- "Create index with invalid mappings": + + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: indices.create: + include_type_name: false index: test_index - do: catch: /illegal_argument_exception/ indices.put_mapping: + include_type_name: false index: test_index - type: test_type body: - test_type: - properties: - "": - type: keyword + properties: + "": + type: keyword + +--- +"PUT mapping with a type and include_type_name: false": + + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + + - do: + indices.create: + index: index + include_type_name: false + + - do: + catch: /illegal_argument_exception/ + indices.put_mapping: + index: index + type: _doc + include_type_name: false + body: + properties: + bar: + type: float + diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/11_basic_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/11_basic_with_types.yml new file mode 100644 index 0000000000000..1d33f2d31bb15 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/11_basic_with_types.yml @@ -0,0 +1,69 @@ +--- +"Test Create and update mapping": + - do: + indices.create: + index: test_index + + - do: + indices.put_mapping: + index: test_index + type: test_type + body: + test_type: + properties: + text1: + type: text + analyzer: whitespace + text2: + type: text + analyzer: whitespace + subfield.text3: + type: text + + - do: + indices.get_mapping: + index: test_index + + - match: {test_index.mappings.test_type.properties.text1.type: text} + - match: {test_index.mappings.test_type.properties.text1.analyzer: whitespace} + - match: {test_index.mappings.test_type.properties.text2.type: text} + - match: {test_index.mappings.test_type.properties.text2.analyzer: whitespace} + + - do: + indices.put_mapping: + index: test_index + type: test_type + body: + test_type: + properties: + text1: + type: text + analyzer: whitespace + fields: + text_raw: + type: keyword + + + - do: + indices.get_mapping: + index: test_index + + - match: {test_index.mappings.test_type.properties.text1.type: text} + - match: {test_index.mappings.test_type.properties.subfield.properties.text3.type: text} + - match: {test_index.mappings.test_type.properties.text1.fields.text_raw.type: keyword} + +--- +"Create index with invalid mappings": + - do: + indices.create: + index: test_index + - do: + catch: /illegal_argument_exception/ + indices.put_mapping: + index: test_index + type: test_type + body: + test_type: + properties: + "": + type: keyword diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/20_no_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/20_no_types.yml deleted file mode 100644 index aa05deb326024..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/20_no_types.yml +++ /dev/null @@ -1,334 +0,0 @@ ---- -"Create indices and manage mappings without types": - - - skip: - version: " - 6.99.99" - reason: include_type_name was introduced in 7.0.0 - - - do: - indices.create: - index: index - include_type_name: false - body: - mappings: - properties: - foo: - type: keyword - - - do: - indices.get_mapping: - index: index - include_type_name: false - - - match: { index.mappings.properties.foo.type: "keyword" } - - - do: - indices.put_mapping: - index: index - include_type_name: false - body: - properties: - bar: - type: float - - - do: - indices.get_mapping: - index: index - include_type_name: false - - - match: { index.mappings.properties.foo.type: "keyword" } - - match: { index.mappings.properties.bar.type: "float" } - ---- -"Index explicit IDs without types": - - - skip: - version: " - 6.99.99" - reason: include_type_name was introduced in 7.0.0 - - - do: - indices.create: - index: index - include_type_name: false - - - do: - index: - include_type_name: false - index: index - id: 1 - body: { foo: bar } - - - match: { "_index": "index" } - - is_false: _type - - - do: - bulk: - index: index - include_type_name: false - body: | - { "index": { "_id": "2" } } - { "doc": { "foo": "baz" } } - - - match: { "items.0.index._index": "index" } - - is_false: items.0.index._type - ---- -"Index implicit IDs without types": - - - skip: - version: " - 6.99.99" - reason: include_type_name was introduced in 7.0.0 - - - do: - indices.create: - index: index - include_type_name: false - - - do: - index: - index: index - include_type_name: false - body: { foo: bar } - - - match: { "_index": "index" } - - is_false: _type - - - do: - bulk: - index: index - include_type_name: false - body: | - { "index": { } } - { "doc": { "foo": "baz" } } - - - match: { "items.0.index._index": "index" } - - is_false: items.0.index._type - ---- -"Mixing include_type_name=false with explicit types": - - - skip: - version: " - 6.99.99" - reason: include_type_name was introduced in 7.0.0 - - - do: - indices.create: - index: index - include_type_name: false - - - do: - catch: /illegal_argument_exception/ - index: - index: index - type: type - id: 1 - include_type_name: false - body: { foo: bar } - - - do: - catch: /illegal_argument_exception/ - index: - index: index - type: type - include_type_name: false - body: { foo: bar } - - - do: - catch: /illegal_argument_exception/ - get: - index: index - type: type - id: 1 - include_type_name: false - - - do: - catch: /illegal_argument_exception/ - update: - index: index - type: type - id: 1 - include_type_name: false - body: - doc: { foo: baz } - - - do: - catch: /illegal_argument_exception/ - delete: - index: index - type: type - id: 1 - include_type_name: false - - - do: - catch: /illegal_argument_exception/ - search: - index: index - type: type - include_type_name: false - - - do: - catch: /illegal_argument_exception/ - search: - index: index - type: _doc - include_type_name: false - ---- -"Update API without types": - - - skip: - version: " - 6.99.99" - reason: include_type_name was introduced in 7.0.0 - - - do: - indices.create: - index: index - include_type_name: false - - - do: - index: - index: index - id: 1 - include_type_name: false - body: { "foo": "bar" } - - - do: - update: - index: index - id: 1 - include_type_name: false - body: - doc: { "foo": "baz" } - - - match: { "_index": "index" } - - is_false: _type - ---- -"GET API without types": - - - skip: - version: " - 6.99.99" - reason: include_type_name was introduced in 7.0.0 - - - do: - indices.create: - index: index - include_type_name: false - - - do: - index: - index: index - id: 1 - include_type_name: false - body: { "foo": "bar" } - - - do: - get: - index: index - id: 1 - include_type_name: false - - - match: { "_index": "index" } - - is_false: _type - ---- -"Delete API without types": - - - skip: - version: " - 6.99.99" - reason: include_type_name was introduced in 7.0.0 - - - do: - indices.create: - index: index - include_type_name: false - - - do: - index: - index: index - id: 1 - include_type_name: false - body: { "foo": "bar" } - - - do: - delete: - index: index - id: 1 - include_type_name: false - - - match: { "_index": "index" } - - is_false: _type - ---- -"Search without types": - - - skip: - version: " - 6.99.99" - reason: include_type_name was introduced in 7.0.0 - - - do: - indices.create: - index: index - include_type_name: false - - - do: - index: - index: index - id: 1 - include_type_name: false - body: { "foo": "bar" } - - - do: - indices.refresh: - index: index - - - do: - search: - index: index - include_type_name: false - - - match: { "hits.total": 1 } - - match: { "hits.hits.0._index": "index" } - - is_false: hits.hits.0._type - ---- -"PUT mapping with a type and include_type_name: false": - - - skip: - version: " - 6.99.99" - reason: include_type_name was introduced in 7.0.0 - - - do: - indices.create: - index: index - include_type_name: false - - - do: - catch: /illegal_argument_exception/ - indices.put_mapping: - index: index - type: _doc - include_type_name: false - body: - properties: - bar: - type: float - ---- -"GET mappings on empty index with the include_type_name=false option": - - - skip: - version: " - 6.99.99" - reason: include_type_name was introduced in 7.0.0 - - - do: - indices.create: - index: index - include_type_name: false - - - do: - indices.get_mapping: - index: index - include_type_name: false - - - match: { index.mappings: {} } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/all_path_options.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/all_path_options.yml index e125ec2a70f4e..c4133e8d01be5 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/all_path_options.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/all_path_options.yml @@ -1,12 +1,19 @@ setup: + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: indices.create: + include_type_name: false index: test_index1 - do: indices.create: + include_type_name: false index: test_index2 - do: indices.create: + include_type_name: false index: foo @@ -14,34 +21,33 @@ setup: "put one mapping per index": - do: indices.put_mapping: + include_type_name: false index: test_index1 - type: test_type body: - test_type: - properties: - text: - type: text - analyzer: whitespace + properties: + text: + type: text + analyzer: whitespace - do: indices.put_mapping: + include_type_name: false index: test_index2 - type: test_type body: - test_type: - properties: - text: - type: text - analyzer: whitespace + properties: + text: + type: text + analyzer: whitespace - do: - indices.get_mapping: {} + indices.get_mapping: + include_type_name: false - - match: {test_index1.mappings.test_type.properties.text.type: text} - - match: {test_index1.mappings.test_type.properties.text.analyzer: whitespace} + - match: {test_index1.mappings.properties.text.type: text} + - match: {test_index1.mappings.properties.text.analyzer: whitespace} - - match: {test_index2.mappings.test_type.properties.text.type: text} - - match: {test_index2.mappings.test_type.properties.text.analyzer: whitespace} + - match: {test_index2.mappings.properties.text.type: text} + - match: {test_index2.mappings.properties.text.analyzer: whitespace} - match: { foo.mappings: {} } @@ -50,73 +56,73 @@ setup: - do: indices.put_mapping: + include_type_name: false index: _all - type: test_type body: - test_type: - properties: - text: - type: text - analyzer: whitespace + properties: + text: + type: text + analyzer: whitespace - do: - indices.get_mapping: {} + indices.get_mapping: + include_type_name: false - - match: {test_index1.mappings.test_type.properties.text.type: text} - - match: {test_index1.mappings.test_type.properties.text.analyzer: whitespace} + - match: {test_index1.mappings.properties.text.type: text} + - match: {test_index1.mappings.properties.text.analyzer: whitespace} - - match: {test_index2.mappings.test_type.properties.text.type: text} - - match: {test_index2.mappings.test_type.properties.text.analyzer: whitespace} + - match: {test_index2.mappings.properties.text.type: text} + - match: {test_index2.mappings.properties.text.analyzer: whitespace} - - match: {foo.mappings.test_type.properties.text.type: text} - - match: {foo.mappings.test_type.properties.text.analyzer: whitespace} + - match: {foo.mappings.properties.text.type: text} + - match: {foo.mappings.properties.text.analyzer: whitespace} --- "put mapping in * index": - do: indices.put_mapping: + include_type_name: false index: "*" - type: test_type body: - test_type: - properties: - text: - type: text - analyzer: whitespace + properties: + text: + type: text + analyzer: whitespace - do: - indices.get_mapping: {} + indices.get_mapping: + include_type_name: false - - match: {test_index1.mappings.test_type.properties.text.type: text} - - match: {test_index1.mappings.test_type.properties.text.analyzer: whitespace} + - match: {test_index1.mappings.properties.text.type: text} + - match: {test_index1.mappings.properties.text.analyzer: whitespace} - - match: {test_index2.mappings.test_type.properties.text.type: text} - - match: {test_index2.mappings.test_type.properties.text.analyzer: whitespace} + - match: {test_index2.mappings.properties.text.type: text} + - match: {test_index2.mappings.properties.text.analyzer: whitespace} - - match: {foo.mappings.test_type.properties.text.type: text} - - match: {foo.mappings.test_type.properties.text.analyzer: whitespace} + - match: {foo.mappings.properties.text.type: text} + - match: {foo.mappings.properties.text.analyzer: whitespace} --- "put mapping in prefix* index": - do: indices.put_mapping: + include_type_name: false index: "test_index*" - type: test_type body: - test_type: - properties: - text: - type: text - analyzer: whitespace + properties: + text: + type: text + analyzer: whitespace - do: - indices.get_mapping: {} + indices.get_mapping: + include_type_name: false - - match: {test_index1.mappings.test_type.properties.text.type: text} - - match: {test_index1.mappings.test_type.properties.text.analyzer: whitespace} + - match: {test_index1.mappings.properties.text.type: text} + - match: {test_index1.mappings.properties.text.analyzer: whitespace} - - match: {test_index2.mappings.test_type.properties.text.type: text} - - match: {test_index2.mappings.test_type.properties.text.analyzer: whitespace} + - match: {test_index2.mappings.properties.text.type: text} + - match: {test_index2.mappings.properties.text.analyzer: whitespace} - match: { foo.mappings: {} } @@ -124,67 +130,34 @@ setup: "put mapping in list of indices": - do: indices.put_mapping: + include_type_name: false index: [test_index1, test_index2] - type: test_type body: - test_type: - properties: - text: - type: text - analyzer: whitespace + properties: + text: + type: text + analyzer: whitespace - do: - indices.get_mapping: {} + indices.get_mapping: + include_type_name: false - - match: {test_index1.mappings.test_type.properties.text.type: text} - - match: {test_index1.mappings.test_type.properties.text.analyzer: whitespace} + - match: {test_index1.mappings.properties.text.type: text} + - match: {test_index1.mappings.properties.text.analyzer: whitespace} - - match: {test_index2.mappings.test_type.properties.text.type: text} - - match: {test_index2.mappings.test_type.properties.text.analyzer: whitespace} + - match: {test_index2.mappings.properties.text.type: text} + - match: {test_index2.mappings.properties.text.analyzer: whitespace} - match: { foo.mappings: {} } ---- -"put mapping with blank index": - - do: - indices.put_mapping: - type: test_type - body: - test_type: - properties: - text: - type: text - analyzer: whitespace - - - do: - indices.get_mapping: {} - - - match: {test_index1.mappings.test_type.properties.text.type: text} - - match: {test_index1.mappings.test_type.properties.text.analyzer: whitespace} - - - match: {test_index2.mappings.test_type.properties.text.type: text} - - match: {test_index2.mappings.test_type.properties.text.analyzer: whitespace} - - - match: {foo.mappings.test_type.properties.text.type: text} - - match: {foo.mappings.test_type.properties.text.analyzer: whitespace} - ---- -"put mapping with missing type": - - - - do: - catch: param - indices.put_mapping: {} - --- "post a mapping with default analyzer twice": - do: indices.put_mapping: + include_type_name: false index: test_index1 - type: test_type body: - test_type: dynamic: false properties: text: @@ -193,18 +166,18 @@ setup: - do: indices.put_mapping: + include_type_name: false index: test_index1 - type: test_type body: - test_type: - dynamic: false - properties: - text: - analyzer: default - type: text + dynamic: false + properties: + text: + analyzer: default + type: text - do: - indices.get_mapping: {} + indices.get_mapping: + include_type_name: false - - match: {test_index1.mappings.test_type.properties.text.type: text} + - match: {test_index1.mappings.properties.text.type: text} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/all_path_options_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/all_path_options_with_types.yml new file mode 100644 index 0000000000000..e125ec2a70f4e --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/all_path_options_with_types.yml @@ -0,0 +1,210 @@ +setup: + - do: + indices.create: + index: test_index1 + - do: + indices.create: + index: test_index2 + - do: + indices.create: + index: foo + + +--- +"put one mapping per index": + - do: + indices.put_mapping: + index: test_index1 + type: test_type + body: + test_type: + properties: + text: + type: text + analyzer: whitespace + - do: + indices.put_mapping: + index: test_index2 + type: test_type + body: + test_type: + properties: + text: + type: text + analyzer: whitespace + + + - do: + indices.get_mapping: {} + + - match: {test_index1.mappings.test_type.properties.text.type: text} + - match: {test_index1.mappings.test_type.properties.text.analyzer: whitespace} + + - match: {test_index2.mappings.test_type.properties.text.type: text} + - match: {test_index2.mappings.test_type.properties.text.analyzer: whitespace} + + - match: { foo.mappings: {} } + +--- +"put mapping in _all index": + + - do: + indices.put_mapping: + index: _all + type: test_type + body: + test_type: + properties: + text: + type: text + analyzer: whitespace + + - do: + indices.get_mapping: {} + + - match: {test_index1.mappings.test_type.properties.text.type: text} + - match: {test_index1.mappings.test_type.properties.text.analyzer: whitespace} + + - match: {test_index2.mappings.test_type.properties.text.type: text} + - match: {test_index2.mappings.test_type.properties.text.analyzer: whitespace} + + - match: {foo.mappings.test_type.properties.text.type: text} + - match: {foo.mappings.test_type.properties.text.analyzer: whitespace} + +--- +"put mapping in * index": + - do: + indices.put_mapping: + index: "*" + type: test_type + body: + test_type: + properties: + text: + type: text + analyzer: whitespace + + - do: + indices.get_mapping: {} + + - match: {test_index1.mappings.test_type.properties.text.type: text} + - match: {test_index1.mappings.test_type.properties.text.analyzer: whitespace} + + - match: {test_index2.mappings.test_type.properties.text.type: text} + - match: {test_index2.mappings.test_type.properties.text.analyzer: whitespace} + + - match: {foo.mappings.test_type.properties.text.type: text} + - match: {foo.mappings.test_type.properties.text.analyzer: whitespace} + +--- +"put mapping in prefix* index": + - do: + indices.put_mapping: + index: "test_index*" + type: test_type + body: + test_type: + properties: + text: + type: text + analyzer: whitespace + + - do: + indices.get_mapping: {} + + - match: {test_index1.mappings.test_type.properties.text.type: text} + - match: {test_index1.mappings.test_type.properties.text.analyzer: whitespace} + + - match: {test_index2.mappings.test_type.properties.text.type: text} + - match: {test_index2.mappings.test_type.properties.text.analyzer: whitespace} + + - match: { foo.mappings: {} } + +--- +"put mapping in list of indices": + - do: + indices.put_mapping: + index: [test_index1, test_index2] + type: test_type + body: + test_type: + properties: + text: + type: text + analyzer: whitespace + + - do: + indices.get_mapping: {} + + - match: {test_index1.mappings.test_type.properties.text.type: text} + - match: {test_index1.mappings.test_type.properties.text.analyzer: whitespace} + + - match: {test_index2.mappings.test_type.properties.text.type: text} + - match: {test_index2.mappings.test_type.properties.text.analyzer: whitespace} + + - match: { foo.mappings: {} } + +--- +"put mapping with blank index": + - do: + indices.put_mapping: + type: test_type + body: + test_type: + properties: + text: + type: text + analyzer: whitespace + + - do: + indices.get_mapping: {} + + - match: {test_index1.mappings.test_type.properties.text.type: text} + - match: {test_index1.mappings.test_type.properties.text.analyzer: whitespace} + + - match: {test_index2.mappings.test_type.properties.text.type: text} + - match: {test_index2.mappings.test_type.properties.text.analyzer: whitespace} + + - match: {foo.mappings.test_type.properties.text.type: text} + - match: {foo.mappings.test_type.properties.text.analyzer: whitespace} + +--- +"put mapping with missing type": + + + - do: + catch: param + indices.put_mapping: {} + +--- +"post a mapping with default analyzer twice": + + - do: + indices.put_mapping: + index: test_index1 + type: test_type + body: + test_type: + dynamic: false + properties: + text: + analyzer: default + type: text + + - do: + indices.put_mapping: + index: test_index1 + type: test_type + body: + test_type: + dynamic: false + properties: + text: + analyzer: default + type: text + + - do: + indices.get_mapping: {} + + - match: {test_index1.mappings.test_type.properties.text.type: text} + diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/search/220_no_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/search/220_no_types.yml new file mode 100644 index 0000000000000..b2489d2ad012e --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/search/220_no_types.yml @@ -0,0 +1,46 @@ +--- +"No type returned": + + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + + - do: + index: + include_type_name: false + index: test_1 + id: 1 + body: {} + - do: + indices.refresh: {} + + - do: + search: + include_type_name: false + index: test_1 + + - length: { hits.hits: 1 } + - match: { hits.hits.0._index: "test_1" } + - is_false: "hits.hits.0._type" + - match: { hits.hits.0._id: "1" } + +--- +"Mixing include_type_name=false with explicit types": + + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + + - do: + catch: /illegal_argument_exception/ + search: + index: index + type: type + include_type_name: false + + - do: + catch: /illegal_argument_exception/ + search: + index: index + type: _doc + include_type_name: false diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/10_doc.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/10_doc.yml index b4581edd350fb..dd5ada3b1f1e9 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/10_doc.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/update/10_doc.yml @@ -1,10 +1,14 @@ --- "Partial document": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: index: + include_type_name: false index: test_1 - type: test id: 1 body: foo: bar @@ -13,8 +17,8 @@ - do: update: + include_type_name: false index: test_1 - type: test id: 1 body: doc: @@ -23,14 +27,14 @@ one: 3 - match: { _index: test_1 } - - match: { _type: test } + - is_false: "_type" - match: { _id: "1" } - match: { _version: 2 } - do: get: + include_type_name: false index: test_1 - type: test id: 1 - match: { _source.foo: baz } @@ -38,3 +42,12 @@ - match: { _source.nested.one: 3 } - match: { _source.nested.two: 2 } + - do: + catch: /illegal_argument_exception/ + update: + index: index + type: type + id: 1 + include_type_name: false + body: + doc: { foo: baz } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/11_shard_header.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/11_shard_header.yml index eb2e4ff9a9117..69f8f7c6427f3 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/11_shard_header.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/update/11_shard_header.yml @@ -1,8 +1,13 @@ --- "Update check shard header": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: indices.create: + include_type_name: false index: foobar body: settings: @@ -15,22 +20,22 @@ - do: index: + include_type_name: false index: foobar - type: baz id: 1 body: { foo: bar } - do: update: + include_type_name: false index: foobar - type: baz id: 1 body: doc: foo: baz - match: { _index: foobar } - - match: { _type: baz } + - is_false: "_type" - match: { _id: "1"} - match: { _version: 2} - match: { _shards.total: 1} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/12_result.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/12_result.yml index 9adada6d54b4f..db4b56eedd391 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/12_result.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/update/12_result.yml @@ -1,10 +1,14 @@ --- "Update result field": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: update: + include_type_name: false index: test_1 - type: test id: 1 body: doc: { foo: bar } @@ -15,8 +19,8 @@ - do: update: + include_type_name: false index: test_1 - type: test id: 1 body: doc: { foo: bar } @@ -27,8 +31,8 @@ - do: update: + include_type_name: false index: test_1 - type: test id: 1 body: doc: { foo: bar } @@ -40,8 +44,8 @@ - do: update: + include_type_name: false index: test_1 - type: test id: 1 body: doc: { foo: baz } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/13_legacy_doc.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/13_legacy_doc.yml new file mode 100644 index 0000000000000..b4581edd350fb --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/update/13_legacy_doc.yml @@ -0,0 +1,40 @@ +--- +"Partial document": + + - do: + index: + index: test_1 + type: test + id: 1 + body: + foo: bar + count: 1 + nested: { one: 1, two: 2 } + + - do: + update: + index: test_1 + type: test + id: 1 + body: + doc: + foo: baz + nested: + one: 3 + + - match: { _index: test_1 } + - match: { _type: test } + - match: { _id: "1" } + - match: { _version: 2 } + + - do: + get: + index: test_1 + type: test + id: 1 + + - match: { _source.foo: baz } + - match: { _source.count: 1 } + - match: { _source.nested.one: 3 } + - match: { _source.nested.two: 2 } + diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/14_shard_header_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/14_shard_header_with_types.yml new file mode 100644 index 0000000000000..eb2e4ff9a9117 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/update/14_shard_header_with_types.yml @@ -0,0 +1,39 @@ +--- +"Update check shard header": + + - do: + indices.create: + index: foobar + body: + settings: + number_of_shards: "1" + number_of_replicas: "0" + + - do: + cluster.health: + wait_for_status: green + + - do: + index: + index: foobar + type: baz + id: 1 + body: { foo: bar } + + - do: + update: + index: foobar + type: baz + id: 1 + body: + doc: + foo: baz + + - match: { _index: foobar } + - match: { _type: baz } + - match: { _id: "1"} + - match: { _version: 2} + - match: { _shards.total: 1} + - match: { _shards.successful: 1} + - match: { _shards.failed: 0} + - is_false: _shards.pending diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/15_result_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/15_result_with_types.yml new file mode 100644 index 0000000000000..9adada6d54b4f --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/update/15_result_with_types.yml @@ -0,0 +1,52 @@ +--- +"Update result field": + + - do: + update: + index: test_1 + type: test + id: 1 + body: + doc: { foo: bar } + doc_as_upsert: true + + - match: { _version: 1 } + - match: { result: created } + + - do: + update: + index: test_1 + type: test + id: 1 + body: + doc: { foo: bar } + doc_as_upsert: true + + - match: { _version: 1 } + - match: { result: noop } + + - do: + update: + index: test_1 + type: test + id: 1 + body: + doc: { foo: bar } + doc_as_upsert: true + detect_noop: false + + - match: { _version: 2 } + - match: { result: updated } + + - do: + update: + index: test_1 + type: test + id: 1 + body: + doc: { foo: baz } + doc_as_upsert: true + detect_noop: true + + - match: { _version: 3 } + - match: { result: updated } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/20_doc_upsert.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/20_doc_upsert.yml index f34e030ff66a0..1595e9d6f8a3f 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/20_doc_upsert.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/update/20_doc_upsert.yml @@ -1,10 +1,14 @@ --- "Doc upsert": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: update: + include_type_name: false index: test_1 - type: test id: 1 body: doc: { foo: bar, count: 1 } @@ -12,8 +16,8 @@ - do: get: + include_type_name: false index: test_1 - type: test id: 1 - match: { _source.foo: baz } @@ -22,8 +26,8 @@ - do: update: + include_type_name: false index: test_1 - type: test id: 1 body: doc: { foo: bar, count: 1 } @@ -31,8 +35,8 @@ - do: get: + include_type_name: false index: test_1 - type: test id: 1 - match: { _source.foo: bar } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/21_doc_upsert_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/21_doc_upsert_with_types.yml new file mode 100644 index 0000000000000..f34e030ff66a0 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/update/21_doc_upsert_with_types.yml @@ -0,0 +1,41 @@ +--- +"Doc upsert": + + - do: + update: + index: test_1 + type: test + id: 1 + body: + doc: { foo: bar, count: 1 } + upsert: { foo: baz } + + - do: + get: + index: test_1 + type: test + id: 1 + + - match: { _source.foo: baz } + - is_false: _source.count + + + - do: + update: + index: test_1 + type: test + id: 1 + body: + doc: { foo: bar, count: 1 } + upsert: { foo: baz } + + - do: + get: + index: test_1 + type: test + id: 1 + + - match: { _source.foo: bar } + - match: { _source.count: 1 } + + diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/22_doc_as_upsert.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/22_doc_as_upsert.yml index 7585b9f3e0b94..884fa3e16f6e8 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/22_doc_as_upsert.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/update/22_doc_as_upsert.yml @@ -1,10 +1,14 @@ --- "Doc as upsert": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: update: + include_type_name: false index: test_1 - type: test id: 1 body: doc: { foo: bar, count: 1 } @@ -12,8 +16,8 @@ - do: get: + include_type_name: false index: test_1 - type: test id: 1 - match: { _source.foo: bar } @@ -22,8 +26,8 @@ - do: update: + include_type_name: false index: test_1 - type: test id: 1 body: doc: { count: 2 } @@ -31,8 +35,8 @@ - do: get: + include_type_name: false index: test_1 - type: test id: 1 - match: { _source.foo: bar } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/24_doc_as_upsert_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/24_doc_as_upsert_with_types.yml new file mode 100644 index 0000000000000..7585b9f3e0b94 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/update/24_doc_as_upsert_with_types.yml @@ -0,0 +1,41 @@ +--- +"Doc as upsert": + + - do: + update: + index: test_1 + type: test + id: 1 + body: + doc: { foo: bar, count: 1 } + doc_as_upsert: true + + - do: + get: + index: test_1 + type: test + id: 1 + + - match: { _source.foo: bar } + - match: { _source.count: 1 } + + + - do: + update: + index: test_1 + type: test + id: 1 + body: + doc: { count: 2 } + doc_as_upsert: true + + - do: + get: + index: test_1 + type: test + id: 1 + + - match: { _source.foo: bar } + - match: { _source.count: 2 } + + diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/30_internal_version.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/30_internal_version.yml index 17c4806c693ac..20ff2020932d4 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/30_internal_version.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/update/30_internal_version.yml @@ -1,11 +1,15 @@ --- "Internal version": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: catch: missing update: + include_type_name: false index: test_1 - type: test id: 1 version: 1 body: @@ -13,8 +17,8 @@ - do: index: + include_type_name: false index: test_1 - type: test id: 1 body: doc: { foo: baz } @@ -22,8 +26,8 @@ - do: catch: conflict update: + include_type_name: false index: test_1 - type: test id: 1 version: 2 body: diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/31_internal_version_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/31_internal_version_with_types.yml new file mode 100644 index 0000000000000..17c4806c693ac --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/update/31_internal_version_with_types.yml @@ -0,0 +1,30 @@ +--- +"Internal version": + + - do: + catch: missing + update: + index: test_1 + type: test + id: 1 + version: 1 + body: + doc: { foo: baz } + + - do: + index: + index: test_1 + type: test + id: 1 + body: + doc: { foo: baz } + + - do: + catch: conflict + update: + index: test_1 + type: test + id: 1 + version: 2 + body: + doc: { foo: baz } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/35_other_versions.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/35_other_versions.yml index c0ec082b91a4f..904d3ce4b4f7a 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/35_other_versions.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/update/35_other_versions.yml @@ -1,11 +1,15 @@ --- "Not supported versions": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: catch: /Validation|Invalid/ update: + include_type_name: false index: test_1 - type: test id: 1 version: 2 version_type: external @@ -16,8 +20,8 @@ - do: catch: /Validation|Invalid/ update: + include_type_name: false index: test_1 - type: test id: 1 version: 2 version_type: external_gte diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/36_other_versions_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/36_other_versions_with_types.yml new file mode 100644 index 0000000000000..c0ec082b91a4f --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/update/36_other_versions_with_types.yml @@ -0,0 +1,27 @@ +--- +"Not supported versions": + + - do: + catch: /Validation|Invalid/ + update: + index: test_1 + type: test + id: 1 + version: 2 + version_type: external + body: + doc: { foo: baz } + upsert: { foo: bar } + + - do: + catch: /Validation|Invalid/ + update: + index: test_1 + type: test + id: 1 + version: 2 + version_type: external_gte + body: + doc: { foo: baz } + upsert: { foo: bar } + diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/40_routing.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/40_routing.yml index 977db506710c7..643d79239d0e4 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/40_routing.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/update/40_routing.yml @@ -1,8 +1,13 @@ --- "Routing": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: indices.create: + include_type_name: false index: test_1 body: settings: @@ -17,8 +22,8 @@ - do: update: + include_type_name: false index: test_1 - type: test id: 1 routing: 5 body: @@ -27,8 +32,8 @@ - do: get: + include_type_name: false index: test_1 - type: test id: 1 routing: 5 stored_fields: _routing @@ -38,16 +43,16 @@ - do: catch: missing update: + include_type_name: false index: test_1 - type: test id: 1 body: doc: { foo: baz } - do: update: + include_type_name: false index: test_1 - type: test id: 1 routing: 5 _source: foo diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/41_routing_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/41_routing_with_types.yml new file mode 100644 index 0000000000000..977db506710c7 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/update/41_routing_with_types.yml @@ -0,0 +1,58 @@ +--- +"Routing": + + - do: + indices.create: + index: test_1 + body: + settings: + index: + number_of_shards: 5 + number_of_routing_shards: 5 + number_of_replicas: 0 + + - do: + cluster.health: + wait_for_status: green + + - do: + update: + index: test_1 + type: test + id: 1 + routing: 5 + body: + doc: { foo: baz } + upsert: { foo: bar } + + - do: + get: + index: test_1 + type: test + id: 1 + routing: 5 + stored_fields: _routing + + - match: { _routing: "5"} + + - do: + catch: missing + update: + index: test_1 + type: test + id: 1 + body: + doc: { foo: baz } + + - do: + update: + index: test_1 + type: test + id: 1 + routing: 5 + _source: foo + body: + doc: { foo: baz } + + - match: { get._source.foo: baz } + diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/60_refresh.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/60_refresh.yml index 8ac1568a1275a..8039edc2e3a05 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/60_refresh.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/update/60_refresh.yml @@ -1,8 +1,13 @@ --- "Refresh": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: indices.create: + include_type_name: false index: test_1 body: settings: @@ -11,8 +16,8 @@ - do: update: + include_type_name: false index: test_1 - type: test id: 1 body: doc: { foo: baz } @@ -20,6 +25,7 @@ - do: search: + include_type_name: false index: test_1 body: query: { term: { _id: 1 }} @@ -28,8 +34,8 @@ - do: update: + include_type_name: false index: test_1 - type: test id: 2 refresh: true body: @@ -39,6 +45,7 @@ - do: search: + include_type_name: false index: test_1 body: query: { term: { _id: 2 }} @@ -47,10 +54,15 @@ --- "When refresh url parameter is an empty string that means \"refresh immediately\"": + + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: index: + include_type_name: false index: test_1 - type: test id: 1 refresh: true body: { foo: bar } @@ -58,8 +70,8 @@ - do: update: + include_type_name: false index: test_1 - type: test id: 1 refresh: "" body: @@ -68,6 +80,7 @@ - do: search: + include_type_name: false index: test_1 body: query: { term: { cat: dog }} @@ -76,10 +89,15 @@ --- "refresh=wait_for waits until changes are visible in search": + + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: index: + include_type_name: false index: update_60_refresh_1 - type: test id: update_60_refresh_id1 body: { foo: bar } refresh: true @@ -87,6 +105,7 @@ - do: search: + include_type_name: false index: update_60_refresh_1 body: query: { term: { _id: update_60_refresh_id1 }} @@ -94,8 +113,8 @@ - do: update: + include_type_name: false index: update_60_refresh_1 - type: test id: update_60_refresh_id1 refresh: wait_for body: @@ -104,6 +123,7 @@ - do: search: + include_type_name: false index: update_60_refresh_1 body: query: { match: { test: asdf } } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/61_refresh_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/61_refresh_with_types.yml new file mode 100644 index 0000000000000..8ac1568a1275a --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/update/61_refresh_with_types.yml @@ -0,0 +1,110 @@ +--- +"Refresh": + + - do: + indices.create: + index: test_1 + body: + settings: + index.refresh_interval: -1 + number_of_replicas: 0 + + - do: + update: + index: test_1 + type: test + id: 1 + body: + doc: { foo: baz } + upsert: { foo: bar } + + - do: + search: + index: test_1 + body: + query: { term: { _id: 1 }} + + - match: { hits.total: 0 } + + - do: + update: + index: test_1 + type: test + id: 2 + refresh: true + body: + doc: { foo: baz } + upsert: { foo: bar } + - is_true: forced_refresh + + - do: + search: + index: test_1 + body: + query: { term: { _id: 2 }} + + - match: { hits.total: 1 } + +--- +"When refresh url parameter is an empty string that means \"refresh immediately\"": + - do: + index: + index: test_1 + type: test + id: 1 + refresh: true + body: { foo: bar } + - is_true: forced_refresh + + - do: + update: + index: test_1 + type: test + id: 1 + refresh: "" + body: + doc: {cat: dog} + - is_true: forced_refresh + + - do: + search: + index: test_1 + body: + query: { term: { cat: dog }} + + - match: { hits.total: 1 } + +--- +"refresh=wait_for waits until changes are visible in search": + - do: + index: + index: update_60_refresh_1 + type: test + id: update_60_refresh_id1 + body: { foo: bar } + refresh: true + - is_true: forced_refresh + + - do: + search: + index: update_60_refresh_1 + body: + query: { term: { _id: update_60_refresh_id1 }} + - match: { hits.total: 1 } + + - do: + update: + index: update_60_refresh_1 + type: test + id: update_60_refresh_id1 + refresh: wait_for + body: + doc: { test: asdf } + - is_false: forced_refresh + + - do: + search: + index: update_60_refresh_1 + body: + query: { match: { test: asdf } } + - match: { hits.total: 1 } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/80_source_filtering.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/80_source_filtering.yml index 4bb22e6b8012e..c69984e5cde39 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/80_source_filtering.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/update/80_source_filtering.yml @@ -1,10 +1,14 @@ --- "Source filtering": + - skip: + version: " - 6.99.99" + reason: include_type_name was introduced in 7.0.0 + - do: update: + include_type_name: false index: test_1 - type: test id: 1 _source: [foo, bar] body: diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/81_source_filtering_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/81_source_filtering_with_types.yml new file mode 100644 index 0000000000000..4bb22e6b8012e --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/update/81_source_filtering_with_types.yml @@ -0,0 +1,19 @@ +--- +"Source filtering": + + - do: + update: + index: test_1 + type: test + id: 1 + _source: [foo, bar] + body: + doc: { foo: baz } + upsert: { foo: bar } + + - match: { get._source.foo: bar } + - is_false: get._source.bar + +# TODO: +# +# - Add _routing diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/85_fields_meta.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/85_fields_meta.yml index f7791d0986399..7838c20085103 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/update/85_fields_meta.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/update/85_fields_meta.yml @@ -7,12 +7,13 @@ - do: indices.create: + include_type_name: false index: test_1 - do: update: + include_type_name: false index: test_1 - type: test id: 1 parent: 5 fields: [ _routing ] @@ -24,8 +25,8 @@ - do: get: + include_type_name: false index: test_1 - type: test id: 1 parent: 5 stored_fields: [ _routing ] diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/update/86_fields_meta_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/update/86_fields_meta_with_types.yml new file mode 100644 index 0000000000000..f7791d0986399 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/update/86_fields_meta_with_types.yml @@ -0,0 +1,33 @@ +--- +"Metadata Fields": + + - skip: + version: "all" + reason: "Update doesn't return metadata fields, waiting for #3259" + + - do: + indices.create: + index: test_1 + + - do: + update: + index: test_1 + type: test + id: 1 + parent: 5 + fields: [ _routing ] + body: + doc: { foo: baz } + upsert: { foo: bar } + + - match: { get._routing: "5" } + + - do: + get: + index: test_1 + type: test + id: 1 + parent: 5 + stored_fields: [ _routing ] + + diff --git a/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/ClientYamlTestSuite.java b/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/ClientYamlTestSuite.java index a8cc96461292a..85796494ba964 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/ClientYamlTestSuite.java +++ b/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/ClientYamlTestSuite.java @@ -21,6 +21,7 @@ import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; +import org.elasticsearch.common.xcontent.XContentParseException; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.yaml.YamlXContent; @@ -73,9 +74,10 @@ public static ClientYamlTestSuite parse(NamedXContentRegistry executeableSection } public static ClientYamlTestSuite parse(String api, String suiteName, XContentParser parser) throws IOException { - parser.nextToken(); - assert parser.currentToken() == XContentParser.Token.START_OBJECT : "expected token to be START_OBJECT but was " - + parser.currentToken(); + if (parser.nextToken() != XContentParser.Token.START_OBJECT) { + throw new XContentParseException(parser.getTokenLocation(), + "expected token to be START_OBJECT but was " + parser.currentToken()); + } ClientYamlTestSuite restTestSuite = new ClientYamlTestSuite(api, suiteName);