Elastic Search : Matching all the values from a multi-value field

I have the exact same problem as asked by

hi all!

I am trying to build query that will match a document only when all the document's values in it's multi-value field are present in the given query.


doc1.multiField: [ A, B, C]
doc2.multiField: [ A, B, C, D]
doc3.multiField: [ A, B]

query.multiField: [ A, B, C, E, F]

So my problem is when I query for values A,B,C, E and F in my index, I want only doc1 and doc3 in my search results, because their multiField values are all contained in my query. doc2 should not be matched, because D is not present in the query.

I am not even sure that this is possible in Elasticsearch. I've been through all the documentation and I would basically need some sort of condition where doc*.multiField.length == doc*.matchedCount or whatever.

minimum_should_match option does not cut it in my case, because it references the number of matching values from the query, whereas I need this condition on the document, which of course differs from document to document.

But there are no answers. Were you able to solve this @Bostjan_Kovac ?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.