{"action":"created","issue":{"url":"https://api.github.com/repos/elasticsearch/elasticsearch/issues/9279","labels_url":"https://api.github.com/repos/elasticsearch/elasticsearch/issues/9279/labels{/name}","comments_url":"https://api.github.com/repos/elasticsearch/elasticsearch/issues/9279/comments","events_url":"https://api.github.com/repos/elasticsearch/elasticsearch/issues/9279/events","html_url":"https://github.com/elasticsearch/elasticsearch/issues/9279","id":54235336,"number":9279,"title":"Remove _analyzer","user":{"login":"rjernst","id":289412,"avatar_url":"https://avatars.githubusercontent.com/u/289412?v=3","gravatar_id":"","url":"https://api.github.com/users/rjernst","html_url":"https://github.com/rjernst","followers_url":"https://api.github.com/users/rjernst/followers","following_url":"https://api.github.com/users/rjernst/following{/other_user}","gists_url":"https://api.github.com/users/rjernst/gists{/gist_id}","starred_url":"https://api.github.com/users/rjernst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rjernst/subscriptions","organizations_url":"https://api.github.com/users/rjernst/orgs","repos_url":"https://api.github.com/users/rjernst/repos","events_url":"https://api.github.com/users/rjernst/events{/privacy}","received_events_url":"https://api.github.com/users/rjernst/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/elasticsearch/elasticsearch/labels/%3AMapping","name":":Mapping","color":"009800"},{"url":"https://api.github.com/repos/elasticsearch/elasticsearch/labels/breaking","name":"breaking","color":"ff0000"},{"url":"https://api.github.com/repos/elasticsearch/elasticsearch/labels/v2.0.0","name":"v2.0.0","color":"dddddd"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-01-13T19:20:16Z","updated_at":"2015-01-16T13:15:41Z","closed_at":null,"body":"### Background\r\nThe most important thing about specifying analyzers is the analyzer used at index time needs to be basically the same as the analyzer used at query time.  If completely different analyzers were to be used, you would either produce terms that could never be found at query time, or query for terms that could never exist in the index.  The API for specifying analyzers on fields does allow to set index and query analyzers separately.  This is to allow things like synonyms where you may want to only add synonyms at index time (yields cheaper queries later), or just add them within the query (more flexible since synonyms can be changed dynamically).\r\n\r\n### `_analyzer` today\r\nToday we have multiple ways to specify which analyzer will be used on text fields.  At indexing time, the order to check is as follows:\r\n1. analyzer for the field\r\n2. `_analyzer` (proposed to remove here)\r\n3. type level default analyzer (will be removed in #8874)\r\n4. index level default analyzer\r\n\r\n`_analyzer` is a special field in the document which specifies the name of an analyzer to use as the default for that document.  This means that the same field for one document can use a completely different analyzer than another document.  The typical use case for this is working with documents in many languages, where each document contains a field specifying which language its main data is in (e.g. subject and body fields). Then at query time, either a single query is used with a “magic” analyzer over that field, or a conjunction of queries that use every analyzer the data may have been indexed with.\r\n\r\n### Problems with `_analyzer`\r\nThe typical use case for `_analyzer` has many problems:\r\n* If using the single analyzer at query time approach, the “magic” analyzer is never good enough.  It cannot possibly cover all the terms that may have been produced by each languages' analyzer, so some terms are never matchable.  For example, “die” in German would be a stop word, while the same word in English is simply a regular word.  Either the magic analyzer removes “die” (in which case English documents about dying can not be found) or it includes it, and German documents that contained it can not match (since the indexing process removed that term).\r\n* Scoring will be skewed. Text relevance models rely on term statistics to weigh the importance of a term for a given document versus the importance of that term for the entire index.  Because some words may analyze to the same term in different languages, the frequencies of terms can be skewed, which will distort where documents matching these words appear in query results.\r\n* Mappings code is already complicated, and this feature further complicates following the logic of where Analyzers are set in code.\r\n* Having multiple ways to set the analyzer used at index or query time is also confusing on users, as they have to decide which way is “better”.\r\n\r\n### Proposal\r\nI propose to remove `_analyzer`, and the associated “analyzer” setting of the match query.  Removing this, along with the type level default in #8874 will simplify specifying analyzers considerably.  There would be no loss of end functionality, since better results can be achieved with multiple fields.\r\n\r\n### Alternatives to `_analyzer`\r\n* One alternative to dealing with multiple languages is to use n-grams. While this can itself be tricky to deal with, it is worth mentioning.\r\n* An alternative that is more directly in line with the current uses of _analyzer is having one field per language.  This requires slight modifications to client code for indexing (copy data into the field for the appropriate language, instead of specifying the language in a field) and querying (query the appropriate language field, instead of selecting an analyzer for that language.  This will produce better results since documents from other languages cannot accidentally appear in the results, and relevance results should be as expected for that language."},"comment":{"url":"https://api.github.com/repos/elasticsearch/elasticsearch/issues/comments/70251726","html_url":"https://github.com/elasticsearch/elasticsearch/issues/9279#issuecomment-70251726","issue_url":"https://api.github.com/repos/elasticsearch/elasticsearch/issues/9279","id":70251726,"user":{"login":"clintongormley","id":56599,"avatar_url":"https://avatars.githubusercontent.com/u/56599?v=3","gravatar_id":"","url":"https://api.github.com/users/clintongormley","html_url":"https://github.com/clintongormley","followers_url":"https://api.github.com/users/clintongormley/followers","following_url":"https://api.github.com/users/clintongormley/following{/other_user}","gists_url":"https://api.github.com/users/clintongormley/gists{/gist_id}","starred_url":"https://api.github.com/users/clintongormley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clintongormley/subscriptions","organizations_url":"https://api.github.com/users/clintongormley/orgs","repos_url":"https://api.github.com/users/clintongormley/repos","events_url":"https://api.github.com/users/clintongormley/events{/privacy}","received_events_url":"https://api.github.com/users/clintongormley/received_events","type":"User","site_admin":false},"created_at":"2015-01-16T13:15:41Z","updated_at":"2015-01-16T13:15:41Z","body":"+1 - the `_analyzer` field is trappy and produces poor results"}}