{"action":"created","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/5359","labels_url":"https://api.github.com/repos/elastic/elasticsearch/issues/5359/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/5359/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/5359/events","html_url":"https://github.com/elastic/elasticsearch/issues/5359","id":28901766,"number":5359,"title":"Add a method to compute alias names for index templates","user":{"login":"rbraley","id":492578,"avatar_url":"https://avatars.githubusercontent.com/u/492578?v=3","gravatar_id":"","url":"https://api.github.com/users/rbraley","html_url":"https://github.com/rbraley","followers_url":"https://api.github.com/users/rbraley/followers","following_url":"https://api.github.com/users/rbraley/following{/other_user}","gists_url":"https://api.github.com/users/rbraley/gists{/gist_id}","starred_url":"https://api.github.com/users/rbraley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rbraley/subscriptions","organizations_url":"https://api.github.com/users/rbraley/orgs","repos_url":"https://api.github.com/users/rbraley/repos","events_url":"https://api.github.com/users/rbraley/events{/privacy}","received_events_url":"https://api.github.com/users/rbraley/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/elastic/elasticsearch/labels/:Aliases","name":":Aliases","color":"009800"},{"url":"https://api.github.com/repos/elastic/elasticsearch/labels/discuss","name":"discuss","color":"fbca04"},{"url":"https://api.github.com/repos/elastic/elasticsearch/labels/enhancement","name":"enhancement","color":"4a4ea8"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":21,"created_at":"2014-03-06T18:20:06Z","updated_at":"2015-09-06T14:14:09Z","closed_at":null,"body":"This is a proposal to extend the functionality to support aliases within templates #5180, #1825, #2739 \r\n\r\nOne use case that the current implementation does not cover is the ability to handle an index per day scenario. In this case it is nice to be able to present a single view of the indices which for the sake of argument look like \"product_elasticsearch_20140306\" as a unified alias which look like \"product_elasticsearch\".\r\n\r\nThe idea is to allow alias names to be formatted similarly to how python handles format strings http://docs.python.org/2/library/string.html#formatstrings\r\n\r\nIf we have a script define the value of the alias's format string parameters then regexes are not required(although still an option) to get a substring of the index name.\r\n\r\nHere is an example:\r\n\r\nPUT _template/template_1\r\n```json\r\n{\r\n    \"template\" : \"product_*\",\r\n    \"settings\" : {\r\n        \"number_of_shards\" : 1\r\n    },\r\n    \"aliases\": {\r\n       \"alias1\" : {},\r\n        \"alias2\" : {\r\n            \"filter\" : {\r\n                \"term\" : {\"user\" : \"kimchy\" }\r\n            },\r\n            \"routing\" : \"kimchy\"\r\n        },\r\n        \"{index}-alias-for-{gender}\": {\r\n            \"filter\" : {\r\n                \"term\" : {\"product\" : \"Elasticsearch\" }\r\n            },\r\n            \"routing\" : \"Elasticsearch\",\r\n            \"format\": {\r\n                \"index\": {\r\n                    \"script\": \"_index['name'].value\",\r\n                },\r\n                \"gender\": {\r\n                    \"script\": \"doc['isFemale'].value ? f : m\",\r\n                    \"params\": {\r\n                        \"m\": \"males\",\r\n                        \"f\": \"females\"\r\n                    }\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/comments/138089057","html_url":"https://github.com/elastic/elasticsearch/issues/5359#issuecomment-138089057","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/5359","id":138089057,"user":{"login":"benbiti","id":13402727,"avatar_url":"https://avatars.githubusercontent.com/u/13402727?v=3","gravatar_id":"","url":"https://api.github.com/users/benbiti","html_url":"https://github.com/benbiti","followers_url":"https://api.github.com/users/benbiti/followers","following_url":"https://api.github.com/users/benbiti/following{/other_user}","gists_url":"https://api.github.com/users/benbiti/gists{/gist_id}","starred_url":"https://api.github.com/users/benbiti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benbiti/subscriptions","organizations_url":"https://api.github.com/users/benbiti/orgs","repos_url":"https://api.github.com/users/benbiti/repos","events_url":"https://api.github.com/users/benbiti/events{/privacy}","received_events_url":"https://api.github.com/users/benbiti/received_events","type":"User","site_admin":false},"created_at":"2015-09-06T14:14:09Z","updated_at":"2015-09-06T14:14:09Z","body":"+1"}}