{"action":"created","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/19163","repository_url":"https://api.github.com/repos/elastic/elasticsearch","labels_url":"https://api.github.com/repos/elastic/elasticsearch/issues/19163/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/19163/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/19163/events","html_url":"https://github.com/elastic/elasticsearch/issues/19163","id":163001610,"number":19163,"title":"ES 5 Doesn't allow registering default analyzer","user":{"login":"mitchswaldman","id":8648823,"avatar_url":"https://avatars.githubusercontent.com/u/8648823?v=3","gravatar_id":"","url":"https://api.github.com/users/mitchswaldman","html_url":"https://github.com/mitchswaldman","followers_url":"https://api.github.com/users/mitchswaldman/followers","following_url":"https://api.github.com/users/mitchswaldman/following{/other_user}","gists_url":"https://api.github.com/users/mitchswaldman/gists{/gist_id}","starred_url":"https://api.github.com/users/mitchswaldman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitchswaldman/subscriptions","organizations_url":"https://api.github.com/users/mitchswaldman/orgs","repos_url":"https://api.github.com/users/mitchswaldman/repos","events_url":"https://api.github.com/users/mitchswaldman/events{/privacy}","received_events_url":"https://api.github.com/users/mitchswaldman/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/elastic/elasticsearch/labels/:Analysis","name":":Analysis","color":"009800"},{"url":"https://api.github.com/repos/elastic/elasticsearch/labels/adoptme","name":"adoptme","color":"207de5"},{"url":"https://api.github.com/repos/elastic/elasticsearch/labels/bug","name":"bug","color":"9e2c2c"},{"url":"https://api.github.com/repos/elastic/elasticsearch/labels/Pioneer%20Program","name":"Pioneer Program","color":"b60205"},{"url":"https://api.github.com/repos/elastic/elasticsearch/labels/v5.0.0","name":"v5.0.0","color":"dddddd"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-06-29T19:02:27Z","updated_at":"2016-06-30T17:21:43Z","closed_at":null,"body":"<!--\r\nGitHub is reserved for bug reports and feature requests. The best place\r\nto ask a general question is at the Elastic Discourse forums at\r\nhttps://discuss.elastic.co. If you are in fact posting a bug report or\r\na feature request, please include one and only one of the below blocks\r\nin your new issue.\r\n-->\r\n\r\n<!--\r\nIf you are filing a bug report, please remove the below feature\r\nrequest block and provide responses for all of the below items.\r\n-->\r\n\r\n**Elasticsearch version**: 5.0.0-alpha3\r\n\r\n**JVM version**: 1.8.0_73-b02\r\n\r\n**OS version**: CentOS Linux release 7.2.1511\r\n\r\n**Description of the problem including expected versus actual behavior**:\r\nI'm trying to upgrade an ES plugin from 2.3 to 5.0.0-alpha3, and a template we previously had working is now causing an issue. The template attempts to set some default analyzers for an index, but when the index is created it throws an error saying there's already an analyzer with the default name. \r\n\r\nHere's the template I'm using:\r\n`{\r\n  \"order\": 0, \r\n  \"settings\": {\r\n    \"index.analysis.analyzer.fairhairIndexAnalyzerv3.alias\": \"default\",\r\n    \"index.analysis.analyzer.fairhairIndexAnalyzerv3.type\": \"fairhair-index-analyzer\",\r\n    \"index.analysis.analyzer.fairhairTokenizingAnalyzer.type\": \"fairhair-tokenizing-analyzer\",\r\n    \"index.analysis.analyzer.fairhairTokenizingAnalyzer.alias\": \"default_search\"\r\n  },\r\n\"mappings\" : {\r\n   //some mappings\r\n},\r\n\"template\" : \"document.*\"\r\n}`\r\n\r\n**Provide logs (if relevant)**:\r\nHere's the error stack trace I get:\r\n`elasticsearch_1  | [2016-06-28 23:40:43,871][DEBUG][action.admin.indices.create] [Iridia] [document.document-20151106] failed to create\r\nelasticsearch_1  | java.lang.IllegalStateException: already registered analyzer with name: default\r\nelasticsearch_1  | \tat org.elasticsearch.index.analysis.AnalysisService.<init>(AnalysisService.java:109)\r\nelasticsearch_1  | \tat org.elasticsearch.index.analysis.AnalysisRegistry.build(AnalysisRegistry.java:161)\r\nelasticsearch_1  | \tat org.elasticsearch.index.IndexService.<init>(IndexService.java:138)\r\nelasticsearch_1  | \tat org.elasticsearch.index.IndexModule.newIndexService(IndexModule.java:328)\r\nelasticsearch_1  | \tat org.elasticsearch.indices.IndicesService.createIndexService(IndicesService.java:398)\r\nelasticsearch_1  | \tat org.elasticsearch.indices.IndicesService.createIndex(IndicesService.java:363)\r\n`\r\n\r\n\r\nI've looked at the AnalysisService class constructor, and I see it does a check for analyzers with the name \"default\" in the passed in analyzer mappings. I believe these conditional statements fire:\r\n\r\n\r\n`if (!analyzerProviders.containsKey(\"default\")) {\r\n            analyzerProviders.put(\"default\", new StandardAnalyzerProvider(indexSettings, null, \"default\", Settings.Builder.EMPTY_SETTINGS));\r\n        }\r\n        if (!analyzerProviders.containsKey(\"default_search\")) {\r\n            analyzerProviders.put(\"default_search\", analyzerProviders.get(\"default\"));\r\n        }\r\n        if (!analyzerProviders.containsKey(\"default_search_quoted\")) {\r\n            analyzerProviders.put(\"default_search_quoted\", analyzerProviders.get(\"default_search\"));\r\n        }`\r\n\r\nSo it registers the standard analyzer, but while iterating through the passed in analyzers, this check also fires:\r\n\r\n`if (analyzers.containsKey(name)) { //Grabs the name from each entry in analyzer map\r\n                throw new IllegalStateException(\"already registered analyzer with name: \" + name);\r\n            }`\r\n\r\nI'm confused as to how both these conditions are firing. This check to see if the current map of analyzers already contains the key \"name\" was introduced in ES 5. \r\n\r\nEDIT: I know why the illegal state exception is being thrown. The Analysis Registry automatically adds the entry: \"default\" => StandardAnalyzer. So from what I can tell, it's actually impossible to register your own default index analyzer, since there will always be the standard analyzer. I think the check for whether a name is already in the analyzer mappings is a bug and should be removed. "},"comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/comments/229727969","html_url":"https://github.com/elastic/elasticsearch/issues/19163#issuecomment-229727969","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/19163","id":229727969,"user":{"login":"mitchswaldman","id":8648823,"avatar_url":"https://avatars.githubusercontent.com/u/8648823?v=3","gravatar_id":"","url":"https://api.github.com/users/mitchswaldman","html_url":"https://github.com/mitchswaldman","followers_url":"https://api.github.com/users/mitchswaldman/followers","following_url":"https://api.github.com/users/mitchswaldman/following{/other_user}","gists_url":"https://api.github.com/users/mitchswaldman/gists{/gist_id}","starred_url":"https://api.github.com/users/mitchswaldman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitchswaldman/subscriptions","organizations_url":"https://api.github.com/users/mitchswaldman/orgs","repos_url":"https://api.github.com/users/mitchswaldman/repos","events_url":"https://api.github.com/users/mitchswaldman/events{/privacy}","received_events_url":"https://api.github.com/users/mitchswaldman/received_events","type":"User","site_admin":false},"created_at":"2016-06-30T17:21:43Z","updated_at":"2016-06-30T17:21:43Z","body":"True. Could you enlighten me on how it's even possible to encounter duplicate keys from the passed in Map? I think I'm missing some crucial understanding of the issue. "}}
{"actor":{"display_login":"mitchswaldman"}}