Skip to content

Commit 55db16e

Browse files
committed
adding a test for index_template_substitutions
1 parent 0805181 commit 55db16e

File tree

2 files changed

+77
-1
lines changed

2 files changed

+77
-1
lines changed

qa/smoke-test-ingest-with-all-dependencies/src/yamlRestTest/resources/rest-api-spec/test/ingest/80_ingest_simulate.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,3 +2009,79 @@ setup:
20092009
- match: { docs.0.doc._index: "subobject-index-1" }
20102010
- match: { docs.0.doc._source.a\.b: "some text" }
20112011
- not_exists: docs.0.doc.error
2012+
2013+
# Now we run the same test but with index_template_substitutions rather than mapping_addition. In this case though,
2014+
# the mappings are _substituted_, not merged. That is, the original template and its mappings are completely replaced
2015+
# with the new one. So the merge_type has no impact.
2016+
- do:
2017+
headers:
2018+
Content-Type: application/json
2019+
simulate.ingest:
2020+
merge_type: "index"
2021+
body: >
2022+
{
2023+
"docs": [
2024+
{
2025+
"_index": "subobject-index-1",
2026+
"_id": "AZgsHA0B41JjTOmNiBKC",
2027+
"_source": {
2028+
"a.b": "some text"
2029+
}
2030+
}
2031+
],
2032+
"index_template_substitutions": {
2033+
"subobject-template": {
2034+
"index_patterns": ["subobject-index*"],
2035+
"template": {
2036+
"mappings": {
2037+
"properties": {
2038+
"a.b": {
2039+
"type": "keyword"
2040+
}
2041+
}
2042+
}
2043+
}
2044+
}
2045+
}
2046+
}
2047+
- length: { docs: 1 }
2048+
- match: { docs.0.doc._index: "subobject-index-1" }
2049+
- match: { docs.0.doc._source.a\.b: "some text" }
2050+
- not_exists: docs.0.doc.error
2051+
2052+
# This makes sure that we get the same result for merge_type "template" for index_template_substitutions
2053+
- do:
2054+
headers:
2055+
Content-Type: application/json
2056+
simulate.ingest:
2057+
merge_type: "template"
2058+
body: >
2059+
{
2060+
"docs": [
2061+
{
2062+
"_index": "subobject-index-1",
2063+
"_id": "AZgsHA0B41JjTOmNiBKC",
2064+
"_source": {
2065+
"a.b": "some text"
2066+
}
2067+
}
2068+
],
2069+
"index_template_substitutions": {
2070+
"subobject-template": {
2071+
"index_patterns": ["subobject-index*"],
2072+
"template": {
2073+
"mappings": {
2074+
"properties": {
2075+
"a.b": {
2076+
"type": "keyword"
2077+
}
2078+
}
2079+
}
2080+
}
2081+
}
2082+
}
2083+
}
2084+
- length: { docs: 1 }
2085+
- match: { docs.0.doc._index: "subobject-index-1" }
2086+
- match: { docs.0.doc._source.a\.b: "some text" }
2087+
- not_exists: docs.0.doc.error

rest-api-spec/src/main/resources/rest-api-spec/api/simulate.ingest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
},
4242
"merge_type":{
4343
"type":"string",
44-
"description":"The mapping merge type if mapping overrides are being provided in mapping_addition, index_template_substitutions, or component_template_substitutions. The allowed values are one of index or template. The index option merges mappings the way they would be merged into an existing index. The template option merges mappings the way they would be merged into a template.",
44+
"description":"The mapping merge type if mapping overrides are being provided in mapping_addition. The allowed values are one of index or template. The index option merges mappings the way they would be merged into an existing index. The template option merges mappings the way they would be merged into a template.",
4545
"default": "index"
4646
}
4747
},

0 commit comments

Comments
 (0)