Skip to content

Add REST APIs for IndexTemplateV2Metadata CRUD #54039

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Mar 27, 2020
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,9 @@ public void testApiNamingConventions() throws Exception {
"cluster.delete_component_template",
"indices.create_data_stream",
"indices.get_data_streams",
"indices.delete_data_stream"
"indices.delete_data_stream",
"indices.put_index_template",
"indices.delete_index_template"
};
//These API are not required for high-level client feature completeness
String[] notRequiredApi = new String[] {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"indices.delete_index_template":{
"documentation":{
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html",
"description":"Deletes an index template."
},
"stability":"stable",
"url":{
"paths":[
{
"path":"/_index_template/{name}",
"methods":[
"DELETE"
],
"parts":{
"name":{
"type":"string",
"description":"The name of the template"
}
}
}
]
},
"params":{
"timeout":{
"type":"time",
"description":"Explicit operation timeout"
},
"master_timeout":{
"type":"time",
"description":"Specify timeout for connection to master"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"indices.get_index_template":{
"documentation":{
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html",
"description":"Returns an index template."
},
"stability":"stable",
"url":{
"paths":[
{
"path":"/_index_template",
"methods":[
"GET"
]
},
{
"path":"/_index_template/{name}",
"methods":[
"GET"
],
"parts":{
"name":{
"type":"list",
"description":"The comma separated names of the index templates"
}
}
}
]
},
"params":{
"flat_settings":{
"type":"boolean",
"description":"Return settings in flat format (default: false)"
},
"master_timeout":{
"type":"time",
"description":"Explicit operation timeout for connection to master node"
},
"local":{
"type":"boolean",
"description":"Return local information, do not retrieve the state from master node (default: false)"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"indices.put_index_template":{
"documentation":{
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html",
"description":"Creates or updates an index template."
},
"stability":"stable",
"url":{
"paths":[
{
"path":"/_index_template/{name}",
"methods":[
"PUT",
"POST"
],
"parts":{
"name":{
"type":"string",
"description":"The name of the template"
}
}
}
]
},
"params":{
"order":{
"type":"number",
"description":"The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers)"
},
"create":{
"type":"boolean",
"description":"Whether the index template should only be added if new or can also replace an existing one",
"default":false
},
"master_timeout":{
"type":"time",
"description":"Specify timeout for connection to master"
}
},
"body":{
"description":"The template definition",
"required":true
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
setup:
- skip:
version: " - 7.99.99"
reason: "index template v2 API has not been backported"

- do:
indices.put_index_template:
name: test
body:
index_patterns: test-*
template:
settings:
number_of_shards: 1
number_of_replicas: 0
mappings:
properties:
field:
type: keyword

---
"Get index template":
- skip:
version: " - 7.99.99"
reason: "index template v2 API has not been backported"

- do:
indices.get_index_template:
name: test

- match: {index_templates.0.name: test}
- match: {index_templates.0.index_template.index_patterns: ["test-*"]}
- match: {index_templates.0.index_template.template.settings: {index: {number_of_shards: '1', number_of_replicas: '0'}}}
- match: {index_templates.0.index_template.template.mappings: {properties: {field: {type: keyword}}}}

---
"Get all tindex emplates":
- skip:
version: " - 7.99.99"
reason: "index template v2 API has not been backported"

- do:
indices.put_index_template:
name: test2
body:
index_patterns: test2-*
template:
settings:
number_of_shards: 1

- do:
indices.get_index_template: {}

- length: {index_templates: 2}

---
"Get index template with local flag":
- skip:
version: " - 7.99.99"
reason: "index template v2 API has not been backported"

- do:
indices.get_index_template:
name: test
local: true

- match: {index_templates.0.name: test}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
setup:
- skip:
version: " - 7.99.99"
reason: "index template v2 API has not been backported"

- do:
indices.delete_index_template:
name: '*'
ignore: 404
---
"Get missing template":
- skip:
version: " - 7.99.99"
reason: "index template v2 API has not been backported"

- do:
catch: missing
indices.get_index_template:
name: test

Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
---
"Put index template":
- skip:
version: " - 7.99.99"
reason: "index template v2 API has not been backported"

- do:
indices.put_index_template:
name: test
body:
index_patterns: test-*
template:
settings:
number_of_shards: 1
number_of_replicas: 0
mappings:
properties:
field:
type: keyword

- do:
indices.get_index_template:
name: test

- match: {index_templates.0.name: "test"}
- match: {index_templates.0.index_template.index_patterns: ["test-*"]}
- match: {index_templates.0.index_template.template.settings.index: {number_of_shards: '1', number_of_replicas: '0'}}
- match: {index_templates.0.index_template.template.mappings: {properties: {field: {type: keyword}}}}

---
"Put multiple index templates":
- skip:
version: " - 7.99.99"
reason: "index template v2 API has not been backported"

- do:
indices.put_index_template:
name: test
body:
index_patterns: [test-*, test2-*]
template:
settings:
number_of_shards: 1
number_of_replicas: 0
mappings:
properties:
field:
type: text
aliases:
test_alias: {}
test_blias: { routing: b }
test_clias: { filter: { term: { user: kimchy }}}

- do:
indices.get_index_template:
name: test

- match: {index_templates.0.index_template.index_patterns: ["test-*", "test2-*"]}
- match: {index_templates.0.index_template.template.settings.index: {number_of_shards: '1', number_of_replicas: '0'}}
- match: {index_templates.0.index_template.template.mappings: {properties: {field: {type: text}}}}
- length: {index_templates.0.index_template.template.aliases: 3}
- is_true: index_templates.0.index_template.template.aliases.test_alias
- match: {index_templates.0.index_template.template.aliases.test_blias.index_routing: "b" }
- match: {index_templates.0.index_template.template.aliases.test_blias.search_routing: "b" }
- match: {index_templates.0.index_template.template.aliases.test_clias.filter.term.user: "kimchy" }

---
"Put index template with 'create' flag":
- skip:
version: " - 7.99.99"
reason: "index template v2 API has not been backported"

- do:
indices.put_index_template:
name: test2
body:
index_patterns: test-*
template:
settings:
number_of_shards: 1
number_of_replicas: 0

- do:
indices.get_index_template:
name: test2

- match: {index_templates.0.index_template.index_patterns: ["test-*"]}
- match: {index_templates.0.index_template.template.settings.index: {number_of_shards: '1', number_of_replicas: '0'}}

- do:
catch: bad_request
indices.put_index_template:
name: test2
create: true
body:
index_patterns: test-*
template:
settings:
number_of_shards: 1
number_of_replicas: 0

---
"Put index template without index_patterns":
- skip:
version: " - 7.99.99"
reason: "index template v2 API has not been backported"

- do:
catch: bad_request
indices.put_index_template:
name: test
body: {}
Loading