匹配 azure documentdb 中的数组内容

matching array content in azure documentdb

是否有生成以下查询的方法?

{ 
  "user": { 
    "name": "john", 
    "tags": ["one", "two", "three"] 
  } 
}

现在给出了一组标签

["one","two","five"]

我想 select 至少有一个与传入标签数组相同的标签的所有用户(如果可能,则不同)。

您必须编写一个用户定义的函数来执行此操作。例如,我在 Whosebug 中搜索 JavaScript 数组交集并找到了这个:Simplest code for array intersection in javascript

您可以在 collection 中将其注册为 UDF,然后像这样查询:

SELECT * FROM docs WHERE udf.ARRAY_INTERSECTS(docs.tags, ["a", "b", "c"]) != []

但是请注意,这需要扫描..