Sometimes it maybe useful to have multiple distinct indexes of a field with different Analyzers. You can use the multi-fields capability to do so.
PUT my_index
{
"mappings": {
"user": {
"properties": {
"name": {
"type": "string"
"analyzer": "standard",
"fields": {
"special": {
"type": "string",
"analyzer": "my_user_name_analyzer"
},
"unanalyzed": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
}
When querying, instead of simply using "user.name" (which in this case would still use the stanard Analyzer) you can use "user.name.special" or "user.name.unanalyzed". Note that the document will remain unchanged, this only affects indexing.