I am trying to create an index template with two patterns, my questions are
- Can I add two patterns in the template?
- Or the only way is to create an index template per pattern?
My policy
PUT _ilm/policy/my_first_policy
{
"policy": {
"phases": {
"hot": {
"actions": {
"rollover": {
"max_primary_shard_size": "1b",
"max_docs": 2
}
}
},
"delete": {
"min_age": "1m",
"actions": {
"delete": {}
}
}
}
}
}
The index template with two patterns
PUT _index_template/my_first_template
{
"index_patterns": ["test-one-*", "test-two-*"],
"template": {
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1,
"index.lifecycle.name": "my_first_policy",
"index.lifecycle.rollover_alias": "my-test-alias"
}
}
}
Start the indices
PUT test-one-000001
{
"aliases": {
"test-one":{
"is_write_index": true
}
}
}
PUT test-two-000001
{
"aliases": {
"test-two":{
"is_write_index": true
}
}
}
I get the following error
illegal_argument_exception: index.lifecycle.rollover_alias [my-test-alias] does not point to index [test-one-000001]
It seems to be working with I have only one pattern in the template and when I use the same alias defined in the template and the first document, this is what I mean
PUT _index_template/my_first_template
{
"index_patterns": ["test-one-*"],
"template": {
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1,
"index.lifecycle.name": "my_first_policy",
"index.lifecycle.rollover_alias": "my-test-alias"
}
}
}
PUT test-one-000001
{
"aliases": {
"my-test-alias":{
"is_write_index": true
}
}
}
CodePudding user response:
the issue here is index.lifecycle.rollover_alias
can only be attached to a single index, it's the write index for that policy
ie - you cannot have two indices attached to an alias that are both write indices