I have a field named tags in my document in elasticsearch with the following structure.
tags = [
{
"id": 10,
"related": [9, 8, 7]
}
]
I now run a filter with a list. e.g. [10, 9]
. I want to filter only those documents which contain all the items in the list either in id or in related. If I search with [9, 8]
, the above document should be returned. If I search with [9, 12]
, the above document shouldn't be returned as 12 isn't present in either id or related.
I tried with terms filter but it simply does or. Is there any technique that can be implemented to achieve the above goal.
Further, I would like to provide a higher ranking to document which contain the given items in id compared to those which contain given items in related
.