简体   繁体   English

带有NOT IN的Azure Cosmos DB Mongo API错误

[英]Azure Cosmos DB Mongo API Bug With NOT IN

I have stored the following document in my Cosmos DB using the Mongo API: 我使用Mongo API将以下文档存储在我的Cosmos DB中:

{
    "_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". 我正在尝试执行一个排除包含标记“Japanese”的任何对象的查询。 I've crafted the following query, which performs correctly (that is, it does not return the above document) on a real Mongo DB: 我已经精心设计了以下查询,该查询在真正的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. 在Cosmos DB上,此查询返回上面的图像,尽管$ nin数组中存在字符串。 Am I doing this query correctly? 我正确地做了这个查询吗? Is there another, supported way for Cosmos DB to do a NOT IN logical operation? 是否有另一种支持的方式让Cosmos DB进行NOT IN逻辑运算?

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: 我有一个与CosmosDB不同的问题,这让我对数组运算进行了一些测试,我相信在你的情况下这应该有效:

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

my issue: 我的问题:

Azure Cosmos DB check if array in field is contained in search array Azure Cosmos DB检查字段中的数组是否包含在搜索数组中

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. 我同意CosmosDB仅实现mongoDB的一个子集的评论,文档非常缺乏,但我希望我提出的修复对你有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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