I've seen this question several times with no adequate answer. What I want to do is to find all documents that contain a subset of values I provide. Example using these docs:
{ "_id":1, "values": [ "A" ] }
{ "_id":2, "values": [ "A", "B" ] }
{ "_id":3, "values": [ "A", "C" ] }
I want to provide [ "A", "D" ] and return only the doc with id 1.
I was able to do this in 2.x by making the field a child of the parent document, then a two step search where I first retrieve all the docs that have at least one value not in the provided list (using a "must not"), then second performing a search with any other criteria AND where the docs do not match the ids found in the first list.
I am now moving to ES 5.6.x and wanted to see if there is an easier way of doing this, particularly getting away from having to use a parent-child relationship or the "newer" join relationship.
It looks like ES 6.1 added the "terms set" query but I don't think that is what I want, unless someone can correct me here.
So is there a way to do this and if so do I need any special mapping (such as nested)? Note that I could potentially have many values in both sets so I need a generic solution, not one where there is only 4 values like my example above.