简体   繁体   中英

Azure Cosmos DB Mongo API Bug With NOT IN

I have stored the following document in my Cosmos DB using the Mongo API:

{
    "_id" : ObjectId("59157eaabfeb1900011592c8"),
    "imageResourceId" : "1489496086018.png",
    "gallery" : "Tst",
    "thumbnailRaw" : {
        "$binary" : "<SNIP>",
        "$type" : "00"
    },
    "tags" : [
        "Weapon/Sword",
        "Japanese"
    ],
    "__v" : 1
}

I'm trying to perform a query that excludes any objects containing the tag "Japanese". I've crafted the following query, which performs correctly (that is, it does not return the above document) on a real Mongo DB:

{"gallery":"Tst, "tags":{"$nin":["Japanese"]}}

On Cosmos DB, this query returns the above image, despite the presence of a string found in the $nin array. Am I doing this query correctly? Is there another, supported way for Cosmos DB to do a NOT IN logical operation?

I have a different issue with CosmosDB, that made me run a few tests on operations with arrays, I believe that in your case this should work:

db.gallery.find({"tags":{"$elemMatch":{$nin: ["japanase"]}}} )

my issue:

Azure Cosmos DB check if array in field is contained in search array

I agree with the comment that CosmosDB is implementing only a subset of mongoDB, and documentation is very scarce, but I hope the fix I propose works for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM