-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Use V2 index templates during index creation #54669
Merged
dakrone
merged 2 commits into
elastic:master
from
dakrone:itv2-actually-use-v2-for-index-creation
Apr 3, 2020
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
188 changes: 188 additions & 0 deletions
188
...-spec/src/main/resources/rest-api-spec/test/indices.put_index_template/15_composition.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,188 @@ | ||
--- | ||
"Component and index template composition": | ||
- skip: | ||
version: " - 7.99.99" | ||
reason: "not yet backported" | ||
|
||
- do: | ||
cluster.put_component_template: | ||
name: ct_low | ||
body: | ||
template: | ||
settings: | ||
number_of_replicas: 1 | ||
mappings: | ||
properties: | ||
field2: | ||
type: text | ||
aliases: | ||
aliasname: | ||
is_write_index: false | ||
|
||
- do: | ||
cluster.put_component_template: | ||
name: ct_high | ||
body: | ||
template: | ||
settings: | ||
index.number_of_replicas: 0 | ||
mappings: | ||
properties: | ||
field2: | ||
type: keyword | ||
aliases: | ||
aliasname: | ||
is_write_index: true | ||
|
||
- do: | ||
indices.put_index_template: | ||
name: my-template | ||
body: | ||
index_patterns: ["foo", "bar-*"] | ||
template: | ||
settings: | ||
index.number_of_shards: 2 | ||
mappings: | ||
properties: | ||
field: | ||
type: keyword | ||
ignore_above: 255 | ||
aliases: | ||
my_alias: {} | ||
aliasname: | ||
filter: | ||
match_all: {} | ||
composed_of: ["ct_low", "ct_high"] | ||
priority: 400 | ||
|
||
- do: | ||
indices.create: | ||
index: bar-baz | ||
body: | ||
settings: | ||
index.priority: 17 | ||
mappings: | ||
properties: | ||
foo: | ||
type: keyword | ||
aliases: | ||
other: {} | ||
|
||
- do: | ||
indices.get: | ||
index: bar-baz | ||
|
||
- match: {bar-baz.settings.index.number_of_shards: "2"} | ||
- match: {bar-baz.settings.index.number_of_replicas: "0"} | ||
- match: {bar-baz.settings.index.priority: "17"} | ||
- match: {bar-baz.mappings.properties.field: {type: keyword, ignore_above: 255}} | ||
- match: {bar-baz.mappings.properties.field2: {type: keyword}} | ||
- match: {bar-baz.mappings.properties.foo: {type: keyword}} | ||
- match: {bar-baz.aliases.aliasname: {filter: {match_all: {}}}} | ||
- match: {bar-baz.aliases.my_alias: {}} | ||
- match: {bar-baz.aliases.other: {}} | ||
|
||
--- | ||
"Index template priority": | ||
- skip: | ||
version: " - 7.99.99" | ||
reason: "not yet backported" | ||
|
||
- do: | ||
indices.put_index_template: | ||
name: my-template | ||
body: | ||
index_patterns: ["foo", "bar-*"] | ||
template: | ||
settings: | ||
index.number_of_shards: 2 | ||
composed_of: [] | ||
priority: 400 | ||
|
||
- do: | ||
indices.put_index_template: | ||
name: another-template | ||
body: | ||
index_patterns: ["bar-*"] | ||
template: | ||
settings: | ||
index.number_of_shards: 3 | ||
composed_of: [] | ||
priority: 405 | ||
|
||
- do: | ||
indices.create: | ||
index: bar-baz | ||
|
||
- do: | ||
indices.get: | ||
index: bar-baz | ||
|
||
- match: {bar-baz.settings.index.number_of_shards: "3"} | ||
|
||
--- | ||
"Component template only composition": | ||
- skip: | ||
version: " - 7.99.99" | ||
reason: "not yet backported" | ||
|
||
- do: | ||
cluster.put_component_template: | ||
name: ct_low | ||
body: | ||
template: | ||
aliases: | ||
alias1: {} | ||
|
||
- do: | ||
cluster.put_component_template: | ||
name: ct_high | ||
body: | ||
template: | ||
mappings: | ||
properties: | ||
field: | ||
type: keyword | ||
|
||
- do: | ||
indices.put_index_template: | ||
name: my-template | ||
body: | ||
index_patterns: ["baz*"] | ||
composed_of: ["ct_low", "ct_high"] | ||
|
||
- do: | ||
indices.create: | ||
index: bazfoo | ||
|
||
- do: | ||
indices.get: | ||
index: bazfoo | ||
|
||
- match: {bazfoo.mappings.properties.field: {type: keyword}} | ||
- match: {bazfoo.aliases.alias1: {}} | ||
|
||
--- | ||
"Index template without component templates": | ||
- skip: | ||
version: " - 7.99.99" | ||
reason: "not yet backported" | ||
|
||
- do: | ||
indices.put_index_template: | ||
name: my-template | ||
body: | ||
index_patterns: ["eggplant"] | ||
template: | ||
settings: | ||
number_of_shards: 3 | ||
|
||
- do: | ||
indices.create: | ||
index: eggplant | ||
|
||
- do: | ||
indices.get: | ||
index: eggplant | ||
|
||
- match: {eggplant.settings.index.number_of_shards: "3"} |
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
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
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 |
---|---|---|
|
@@ -307,7 +307,7 @@ static boolean resolvePipelines(final DocWriteRequest<?> originalRequest, final | |
} | ||
} else if (indexRequest.index() != null) { | ||
// the index does not exist yet (and this is a valid request), so match index templates to look for pipelines | ||
List<IndexTemplateMetadata> templates = MetadataIndexTemplateService.findTemplates(metadata, indexRequest.index(), null); | ||
List<IndexTemplateMetadata> templates = MetadataIndexTemplateService.findV1Templates(metadata, indexRequest.index(), null); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we also check v2 templates here, if default/final pipeline has been specified? If so then I think it is fine to do this in a follow up pr. |
||
assert (templates != null); | ||
// order of templates are highest order first | ||
for (final IndexTemplateMetadata template : templates) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check v2 templates here too? If so, then I think it is ok to do this in a followup change as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely, I'll be addressing these in followups!