I want to find blenders in elastic of a certain name & color and brand. To do this, specify 3 fields for the search, specifying in which field elastic should start the search. Elastic returns products that I have not searched for.
Request length can be any, for example, I decided to find blenders in black color of a certain brand but the query can include anything.
POST products/_search
{
"_source": [ "Title","Brand", "SKU", "Color" ], //which field do I want to get in result json
"query": {
"multi_match" : {
"query" : "blender hendi black", // input query
"fields": ["Brand","Title", "Color"], //search fields
"minimum_should_match": "2", // I also tried query without this attribute
"fuzziness": 1 //misspelling // I also tried query without this attribute
}
},
"size": 10
}
Elastic result:
There are only two objects in this example, and I check the whole response, it will very often contain products that are not relevant
{
"took": 5,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 3,
"relation": "eq"
},
"max_score": 10.110109,
"hits": [
{
"_index": "products",
"_id": "2ymTUYcBoby_8DNrw9q0",
"_score": 10.110109,
"_ignored": [
"event.original.keyword",
"Long_description.keyword"
],
"_source": {
"Brand": "saro",
"Title": "Cup blender black 2 L, 0.95 kW",
"Color": "Black",
"SKU": "329-20151"
}
},
{
"_index": "products",
"_id": "sCmSUYcBoby_8DNr4WZp",
"_score": 9.749819,
"_ignored": [
"event.original.keyword"
],
"_source": {
"Brand": "hendi",
"Title": "Replacement die for Hendi sealing machine made of polished aluminum Black silicone gasket",
"Color": "Silver",
"SKU": "HEN-805589"
}
}
}
]
}
}
I understand why elastic finds products that are not blenders, because in the title occurs the name of the color and the product brand name, which turns out to be a match for the two words from the query. How can I solve this problem? How to make elastic return only what I expect?
I did not change anything in the mapping it created itself
{
"products": {
"mappings": {
"properties": {
"@timestamp": {
"type": "date"
},
"@version": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"Color": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"Brand": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"Title": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
I didn't change the standard mapping. I keep all products in the same index. Although I have quite different products with a different number of fields, is it ok to store different entities in the same index, is it ok at all? I couldn't find a specific answer