ElasticSearch - search using abbreviations
1 answer
You can use a synonym token for a custom parser.
For example, the following displays
{
"settings": {
"analysis": {
"analyzer": {
"my_analyzer": {
"tokenizer": "standard",
"filter": ["lowercase", "synonym_filter"]
}
},
"filter": {
"synonym_filter": {
"type": "synonym",
"synonyms": [
"bank of america,boa"
],
"expand": true
}
}
}
},
"mappings": {
"document": {
"properties": {
"text": {
"type": "text",
"analyzer": "my_analyzer",
"fielddata": true
}
}
}
}
}
You can definitely add more to the list or use a synonym file.
For usecases requests BOfA or BOA, BofA - two approaches can be used.
1) More synonyms with this possible combination
"synonyms": [
"bank of america,boa"
"bank of america,bofa"
]
2) or keep abbreviations intact and use fuzzy query
{
"query": {
"match": {
"text" : {
"query": "bofa",
"fuzziness": 2
}
}
}
}
You will need synonyms to provide ES abbreviations.
0
source to share