I have an Microsoft Azure CosmosDB MongoDB Api database and I am trying to get all the documents where one array field is fully contained in my search array.
So, what I am looking for is, given the collection test containing the documents:
{"id":1,"filters":[1,2]}
{"id":2,"filters":[1,3]}
if I execute:
db.test.find({"filters":{"$elemMatch":{$nin: [1,3]}}})
I get back:
{"id":1,"filters":[1,2]}
However, if I negate it, since I want all the documents with filters fully contained in my search, the full list of documents is returned.
db.test.find({"filters":{$not:{"$elemMatch":{$nin: [1,3]}}}})
returns:
{"id":1,"filters":[1,2]}
{"id":2,"filters":[1,3]}
contrary to what is mentioned in the article: Check if every element in array matches condition
I also tried the $issubset on an aggregation , to no avail ( 0 results ) :
db.test.aggregate([{$match:{$issubset:["$filters",[1,3]]}}])
I even tried ( 0 results ):
db.test.aggregate([{$match:{$issubset:[[1],[1,3]]}}])
Anyone with an idea of what is happening her?
Is it my error?
List item Am I using mongoDB features not implemented in CosmosDB yet?
Is it CosmosDB bug?
Thank you!