I’m trying to solve how an OpenSearch index and its mappings must be configured to allow searching with quotes to find an exact match of the search term.
Currently, all fields are of type text
and no tokenizer or analyzer is defined on the index or the field mappings. So everything is default.
PUT /items/_mappings
{
"properties": {
...
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
...
}
Search example 1: name=ABC
returns items whose name contains “ABC”. As expected.
Search example 2: name="ABC"
currently returns a list of matches, including ABC
but also ABC DEF EFG
, ABC foo
, bar ABC
etc. So all items whose name CONTAINS “ABC” are also returned.
So how do I configure the index so that name="ABC"
return only the item named ‘ABC’?
Usually the search is done without the quotes, which correctly returns all items whose name contains “ABC”. The quotes should tell OpenSearch to “please only give me the exact match”.
I hope this makes sense. Thank you!