Cosmos SQL API:基于数组条目的过滤器

Cosmos SQL API: filter based an array entry

鉴于 json

{
    "fileIds": [
        "171824c7-1485-4b35-9418-2b40aea8fa48",
        "b158e946-621f-431e-926c-57577e3e0b6b"
    ],
    "eventType": 8,
    "description": "File deleted from original storage account",
    "registerTimeUtc": "0001-01-01T00:00:00",
    "customerId": "c7b00078-8fd7-49ad-989a-2fabcb767f6e",
    "applicationId": "266c6ca3-e77c-4233-b780-b8dd69aa7349"
    ...     

}

我需要根据给定的 applicationId、eventType 和 fileId 检查条目是否存在,但我不知道如何编写基于 fileId 的查询来检查它是否存在于数组列表中。

请尝试以下查询:

SELECT * FROM Root r where 
    r.applicationId = '266c6ca3-e77c-4233-b780-b8dd69aa7349' and 
    r.eventType = 8 and 
    ARRAY_CONTAINS(r.fileIds, '171824c7-1485-4b35-9418-2b40aea8fa48')

要搜索数组中的项目,您需要使用 ARRAY_CONTAINS 函数。