elasticsearch - Multi-fields in elasticsearch - elastic - elastic search - elasticsearch tutorial - elasticsearch docker
Multi-fields in elasticsearch
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"
}
}
}
}
}
}
}Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - elasticsearch - elasticsearch tutorial - elastic - elastic search - elasticsearch docker team
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.