I have data in elasticsearch fields which contains "face mask", I am able to fetch this data with the following query with search_term set to "face", "face mask", "mask" and "face masks".
{
"query": {
"bool": {
"must": [{
"multi_match": {
"query": ${search_term},
"fields": [
"title^4",
"titleNgram^3",
],
"fuzziness": "auto"
}
}]
}
}
}
What I am not able to achieve is when I query for "facemask" (no spaces in search_term) it does not return any document containing "face" or "mask", but, it returns documents with fields containing "facewash". Is there a way to achieve it?
Mapping is shared below
{
"mappings": {
"_doc": {
"properties": {
"title": {
"type": "text"
},
"titleNgram": {
"search_analyzer": "whitespace_analyzer",
"analyzer": "nGram_analyzer",
"type": "text"
},
"id": {
"index": false,
"type": "text"
}
}
}
}
}