Elasticsearch index tempalte aliases


(Learnning Golang) #1

Hi, Every body, I want to implement an automatic alias based on the field when the index is created.

This is a index template setting configuartion;
{
"order": 5,
"version": 60001,
"index_patterns": [
"debug*"
],
"settings": {
"index": {
"number_of_shards": "1",
"number_of_replicas": "0",
"refresh_interval": "1s"
}
},
"mappings": {
"doc": {
"properties": {
"logLevel": {
"type": "keyword"
},
"hostname": {
"type": "keyword"
},
"application": {
"type": "keyword"
}
}
}
},
"aliases": {
"{application}-alias-for-{env}": {
"format": {
"env": {
"lang": "expression",
"script": "doc['logLevel'].value"
},
"application": {
"lang": "expression",
"script": "doc['application'].value"
}
}
}
}
}


(Junaid) #2

I dont think so this is supported. Templates are applied over index at the time of index creation, not at the time of document indexing. I have seen any method of defining custom placeholders. As per the documentation only index placeholder is supported.

https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html


(Learnning Golang) #3

Yes, I know. Just see someone using it.