-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjust /_cat/templates not to request all metadata (#78812)
Today `GET /_cat/templates` retrieves the whole cluster metadata from the master, which includes all sorts of unnecessary junk and consumes significant resources. This commit reimplements these endpoints using `GetIndexTemplatesAction` and `GetComposableIndexTemplateAction` which are much more efficient. The docs for this API indicate that it accepts a comma-separated list of template names/patterns of the form `GET /_cat/templates/name1,name2` but in fact today it only accepts a single name or pattern. This commit also adds support for multiple names/patterns as the docs claim.
- Loading branch information
1 parent
dd4e4c3
commit b07dbe5
Showing
2 changed files
with
284 additions
and
35 deletions.
There are no files selected for viewing
179 changes: 179 additions & 0 deletions
179
rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/cat.templates/20_matching.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
setup: | ||
- do: | ||
indices.put_template: | ||
name: test-legacy-1 | ||
body: | ||
order: 12 | ||
version: 3 | ||
index_patterns: foo* | ||
|
||
- do: | ||
indices.put_template: | ||
name: test-legacy-2 | ||
body: | ||
order: 45 | ||
version: 6 | ||
index_patterns: | ||
- bar* | ||
- baz* | ||
|
||
- do: | ||
cluster.put_component_template: | ||
name: test-component-template | ||
body: | ||
template: | ||
settings: | ||
number_of_shards: 1 | ||
number_of_replicas: 0 | ||
|
||
- do: | ||
indices.put_index_template: | ||
name: test-composable-1 | ||
body: | ||
index_patterns: | ||
- quux* | ||
priority: 78 | ||
version: 9 | ||
composed_of: | ||
- test-component-template | ||
|
||
- do: | ||
indices.put_index_template: | ||
name: test-composable-2 | ||
body: | ||
index_patterns: | ||
- gruly* | ||
priority: 99 | ||
version: 1 | ||
composed_of: | ||
- test-component-template | ||
|
||
--- | ||
"Matching all templates": | ||
|
||
- do: | ||
cat.templates: | ||
h: [name] | ||
s: [name] | ||
|
||
- match: | ||
$body: /test-composable-1\ntest-composable-2\ntest-legacy-1\ntest-legacy-2\n/ | ||
|
||
- do: | ||
cat.templates: | ||
name: "*" | ||
h: [name] | ||
s: [name] | ||
|
||
- match: | ||
$body: /test-composable-1\ntest-composable-2\ntest-legacy-1\ntest-legacy-2\n/ | ||
|
||
--- | ||
"Matching all templates with other patterns": | ||
- skip: | ||
version: " - 7.99.99" | ||
reason: "support for multiple patterns added in 8.0.0" | ||
|
||
- do: | ||
cat.templates: | ||
name: "nonexistent*,*,other-name" | ||
h: [name] | ||
s: [name] | ||
|
||
- match: | ||
$body: /test-composable-1\ntest-composable-2\ntest-legacy-1\ntest-legacy-2\n/ | ||
|
||
--- | ||
"Matching no templates": | ||
|
||
- do: | ||
cat.templates: | ||
name: "nonexistent" | ||
h: [name] | ||
s: [name] | ||
|
||
- match: | ||
$body: /^$/ | ||
|
||
--- | ||
"Matching single names": | ||
|
||
- do: | ||
cat.templates: | ||
name: "test-legacy-1" | ||
h: [name] | ||
s: [name] | ||
|
||
- match: | ||
$body: /^test-legacy-1\n$/ | ||
|
||
|
||
- do: | ||
cat.templates: | ||
name: "test-composable-2" | ||
h: [name] | ||
s: [name] | ||
|
||
- match: | ||
$body: /^test-composable-2\n$/ | ||
|
||
--- | ||
"Matching single patterns": | ||
|
||
- do: | ||
cat.templates: | ||
name: "test-legacy-*" | ||
h: [name] | ||
s: [name] | ||
|
||
- match: | ||
$body: /^test-legacy-1\ntest-legacy-2\n$/ | ||
|
||
|
||
- do: | ||
cat.templates: | ||
name: "test-*-2" | ||
h: [name] | ||
s: [name] | ||
|
||
- match: | ||
$body: /^test-composable-2\ntest-legacy-2\n$/ | ||
|
||
--- | ||
"Matching lists of names": | ||
- skip: | ||
version: " - 7.99.99" | ||
reason: "support for multiple patterns added in 8.0.0" | ||
|
||
- do: | ||
cat.templates: | ||
name: "test-legacy-1,test-composable-2" | ||
h: [name] | ||
s: [name] | ||
|
||
- match: | ||
$body: /^test-composable-2\ntest-legacy-1\n$/ | ||
|
||
--- | ||
"Matching names and wildcards": | ||
- skip: | ||
version: " - 7.99.99" | ||
reason: "support for multiple patterns added in 8.0.0" | ||
|
||
- do: | ||
cat.templates: | ||
name: "test-legacy-1,test-composable-*" | ||
h: [name] | ||
s: [name] | ||
|
||
- match: | ||
$body: /^test-composable-1\ntest-composable-2\ntest-legacy-1\n$/ | ||
|
||
- do: | ||
cat.templates: | ||
name: "test-legacy-*,test-composable-2" | ||
h: [name] | ||
s: [name] | ||
|
||
- match: | ||
$body: /^test-composable-2\ntest-legacy-1\ntest-legacy-2\n$/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters