I have my collection like below
{
"_id" : NumberLong(366),
"_class" : "com.cts.adpart.domain.DBData",
"file" : "xyz",
"sample" : [
"a",
"b",
"c"
]
}
I want to search sample array based on list values Suppose now 1. my List is having values "a","c" then i want above document to be returned but, 2. if my list contains "a","d" It should not return above document.
I have tried below code but it is returning me the document even if one match is found.
List<String> sampleList = new ArrayList<String>();
sampleList.add("a");
sampleList.add("d");
query.addCriteria(Criteria.where("sample").in(sampleList));
How to change the query so that it returns document only if all values in list matches the field?