HI Guys ,
I have few indexes patterns that i want to create alias for "wakeupsms" by default.
i already did POST _aliases and it work but didn't effect for new indices .
i tried to put template by the following command but i think i miss something because nothing happend:
PUT _template/wakeupsms
{
"order" : 0,
"index_patterns" : [
"prod-env-jobs-*",
"pre_prod-xxx-listener-*"
],
"settings" : {
"index" : {
"lifecycle" : {
"name" : "index-policy"
},
"number_of_shards" : "5",
"number_of_replicas" : "0"
}
},
"mappings" : { },
"aliases" : {
"alias1" : {},
"{index}-prod-wakeupsms" : {}
}
}
what is the solution?
Thanks,
spinscale
(Alexander Reelsen)
July 3, 2019, 8:27am
2
Hey,
take this example. The first part of the alias is actually the alias name, so no need to specify {index}
in there
PUT _template/foo-template
{
"index_patterns" : ["foo-*"],
"aliases" : {
"my-alias" : {}
}
}
PUT foo-1/_doc/1
{
"key" : "1"
}
PUT foo-2/_doc/2
{
"key" : "2"
}
PUT foo-3/_doc/3
{
"key" : "3"
}
GET my-alias/_search
Hope I understood your request correctly.
--Alex
Hi i understood , thanks alot!!!!
PUT _template/wakeupsms
{
"order" : 0,
"index_patterns" : [
"prod-env-jobs-*",
"pre_prod-xxx-listener-*"
],
"settings" : {
"index" : {
"lifecycle" : {
"name" : "index-policy"
},
"number_of_shards" : "5",
"number_of_replicas" : "0"
}
},
"mappings" : { },
"aliases" : {
"wakeupsms" : {},
}
Hey! thanks for quick respond
should I rebuild index after put the changes?
spinscale
(Alexander Reelsen)
July 3, 2019, 1:02pm
5
this is only about creating the index template that only applies on new index creation.
What makes you think you need to rebuild? The short answer is 'no' but I am curious about the reasoning here.
because the template is for specified indexes that already in the system and new indexes that will be create everyday
spinscale
(Alexander Reelsen)
July 3, 2019, 2:37pm
7
the template is only applied when a new index is created, never on existing indices.
See the note right at the top at https://www.elastic.co/guide/en/elasticsearch/reference/7.2/indices-templates.html
Great! I knew it just wanted to double check in case of aliases as well
thanks alot
1 Like
system
(system)
Closed
July 31, 2019, 3:24pm
9
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.