From elasticsearch 5.x string type is disabled. Instead elasticsearch has introduced two types text and keyword. Read this blog for the reasons for migrating data https://www.elastic.co/blog/strings-are-dead-long-live-strings
So instead of adding a template to disable analyzer, you could simply use field.keyword for exact search.
e.g. If field name is fullName, and you have entries
- fullName:"John Doe"
- fullName:"John"
then, fullName:"John" will return two results, while fullName.keyword:"John" will return single record.
Just in case, you still want to disable text field, you can use the below dynamic template,
PUT _template/disable_all_analyzer
{
"template": "*",
"mappings": {
"_default_": {
"dynamic_templates": [
{ "notanalyzed": {
"match": "*",
"match_mapping_type": "string",
"mapping": {
"type": "keyword"
}
}
}
]
}
}
}
Cheers!!!