Hi,
I am trying to automatically create an index that does not already exist by applying an index template with an alias definition.
Template looks like this:
PUT _template/my_template
{
"index_patterns" : ["*"],
"aliases" : {
"{index}_alias" : {}
}
}
If I then index the first document:
POST /index1/_doc/
{
"hello": "world"
}
It works as expected with both index and alias automatically created:
GET /_aliases
{
"index1" : {
"aliases" : {
"index1_alias" : { }
}
}
}
My problem is that I don't know an index name until I get a document to index and I have been relying on automatic index creation so far. I would now like to only use index aliases in all API calls to future proof my application.
So, if I index the first document with an alias like this:
POST /index2_alias/_doc/
{
"hello": "world"
}
I would like to get this:
GET /_aliases
{
"index2" : {
"aliases" : {
"index2_alias" : { }
}
}
}
Is that possible?
Thank you,
Vlad