Reputation: 4989
I used to use double quotes to achieve "exact match" (here it does not mean exact match on term level, "Nike Air" should match "nike air", but should not match "Nike Air Force") in older ES version (2.x, 5.x):
GET some-index/_search
{
"query": {
"match": {
"brandName": "\"Nike Air\""
}
}
}
So I only get "Nike Air" and not "Nike Air Force". But the query is not working under ES 7 - "Nike Air Force" is also returned. How can I achieve the same under ES 7?
Here is the mapping definition of some-index
:
{
"some-index" : {
"mappings" : {
"properties" : {
"brandName" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
}
}
}
Upvotes: 0
Views: 850
Reputation: 9099
Match query searches for tokens. So it searches for token nike and air in documents
If you intend to do exact match use term query on keyword field
"query": {
"term": {
"brandName.keyword": "Nike Air"
}
}
Upvotes: 2