Estimation of an array of elastic searches

I have a document having an array like

doc1

{ "item_type":"bag", "color":["red","blue","green","orange"] } 

doc2

 { "item_type":"shirt", "color":["red"] } 

when I search on several parameters, for example

{ "query": { "multi_match": { "query": "red bag", "type": "cross_fields", "fields": ["item_type","color"] } } }

Doc2 has a much higher score, I understand that in the color box submitted, fewer objects get a higher score, and this gets worse if I have more colors in doc1.

So, is there a way I can ask Elasticsearch to hammer the same thing for an array field no matter how many elements there are?

+6
source share
1 answer

If you do not want to take into account the length of the field (fieldNorm) during scoring, you can turn off the norms for the field in the match.

For example, the mapping for the above example would be

  { "properties": { "item_type": { "type": "string" }, "color": { "type": "string", "norms": { "enabled": false } } } } 

This article from the final elasticsearch tutorial gives a good idea of โ€‹โ€‹field length norms.

+4
source

Source: https://habr.com/ru/post/987566/


All Articles