Reputation: 4748
Example documents:
{"id": 1, "categories" : ["A", "C","E"]}
{"id": 2, "categories" : ["A", "C"]}
{"id": 3, "categories" : ["A"]}
{"id": 4, "categories" : ["A"]}
When someone searches for a single value "A" in the categories
field, how can I make sure that document 3 and 4 will always be in higher order than document 1 and 2 since they are closer to the single value "A"?
I have tried this query:
{
"query": {
"bool": {
"filter": {
"bool": {
"must": [
{
"term": {
"categories": "A"
}
}
]
}
}
}
}
}
but document 3 and 4 are not in top order.
Upvotes: 0
Views: 48
Reputation: 896
It is not possible to control the relevance or the tf/idf
when you are trying to work on cells inside an array. The elasticsearch will treat all the cells and their content like one concatenated string.
Upvotes: 1