{"action":"opened","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/22260","repository_url":"https://api.github.com/repos/elastic/elasticsearch","labels_url":"https://api.github.com/repos/elastic/elasticsearch/issues/22260/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/22260/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/22260/events","html_url":"https://github.com/elastic/elasticsearch/issues/22260","id":196409424,"number":22260,"title":"Add Ability to Create Index Based on Alias Name For Index Templates","user":{"login":"eladmena","id":20152625,"avatar_url":"https://avatars.githubusercontent.com/u/20152625?v=3","gravatar_id":"","url":"https://api.github.com/users/eladmena","html_url":"https://github.com/eladmena","followers_url":"https://api.github.com/users/eladmena/followers","following_url":"https://api.github.com/users/eladmena/following{/other_user}","gists_url":"https://api.github.com/users/eladmena/gists{/gist_id}","starred_url":"https://api.github.com/users/eladmena/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eladmena/subscriptions","organizations_url":"https://api.github.com/users/eladmena/orgs","repos_url":"https://api.github.com/users/eladmena/repos","events_url":"https://api.github.com/users/eladmena/events{/privacy}","received_events_url":"https://api.github.com/users/eladmena/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-12-19T13:07:25Z","updated_at":"2016-12-19T13:07:25Z","closed_at":null,"body":"Index templates allow specifying that alias(es) will be created once a index is dynamically created.\r\nWhen adding a new document the index matching the name will be created.\r\n\r\nAs I'd prefer consumer to use the alias rather than the index, it means that the when using templates the initial document PUT should be with the index name and only then use the alias name, which beats the purpose of index templates as I need different behaviour for the first put.\r\n\r\nfor example for this template\r\n{\r\n  \"template\": \"**XXX_***\",\r\n  \"mappings\": {\r\n    \"type01\": {\r\n      \"properties\": {\r\n        \"field01\": {\"type\": \"text\"}\r\n      }\r\n    }\r\n  },\r\n  \"aliases\": {\r\n\t\"{index}_alias\" : {}\r\n  }\r\n}\r\n\r\nput for XXX_A_alias will create:\r\n\r\n- index named XXX_A_alias\r\n\r\n- alias named XXX_A_alias_alias\r\nwhile the intention was to create index named XXX_A and alias named XXX_A_alias\r\n\r\nIt would be best to add **preferAliasAsSourceName** property to infer index name from the alias, in case the matched name also matches the alias.\r\nie: \r\n{\r\n  \"template\": \"**XXX_***\",\r\n  \"mappings\": {\r\n    \"type01\": {\r\n      \"properties\": {\r\n        \"field01\": {\"type\": \"text\"}\r\n      }\r\n    }\r\n  },\r\n  **\"preferAliasAsSourceName\": true,**\r\n  \"aliases\": {\r\n\t\"{index}_alias\" : {}\r\n  }\r\n}\r\n\r\nXXX_A_alias matches the alias name, and {index} = XXX_A as such the index name will be XXX_A"}}
{"actor":{"display_login":"eladmena"}}