Commercetools - 使用查询谓词过滤集合属性

Commercetools - Use query predicates to filter on a collection attribute

我想获取所有在其祖先之间具有某个祖先的类别项目 "id"。

这是 GETting 从 /categories 返回的类别之一的 JSON:

{
        "id": "4627f3b0-fe52-4cc6-b03e-3fd72e701342",
        "version": 1,
        "lastMessageSequenceNumber": 1,
        "createdAt": "2019-02-18T13:48:51.677Z",
        "lastModifiedAt": "2019-02-18T13:48:51.677Z",
        "lastModifiedBy": {
            "clientId": "_anonymous"
        },
        "createdBy": {
            "clientId": "_anonymous"
        },
        "key": "snowboard-gloves",
        "name": {
            "en": "Snowboard Gloves"
        },
        "slug": {
            "en": "snowboard-gloves"
        },
        "description": {
            "en": "Gloves specifically designed for snowboarding"
        },
        "ancestors": [
            {
                "typeId": "category",
                "id": "b27086d2-33f2-43c3-aad1-4c01b2b9a886"
            }
        ],
        "parent": {
            "typeId": "category",
            "id": "b27086d2-33f2-43c3-aad1-4c01b2b9a886"
        },
        "orderHint": "0.000016",
        "metaTitle": {
            "en": "Snowboard Gloves"
        },
        "metaDescription": {
            "en": "Gloves specifically designed for snowboarding"
        },
        "assets": []
    }

我想在 ancestors[x].id = "b27086d2-33f2-43c3-aad1-4c01b2b9a886" 上使用 where 子句调用 /categories API,但来自 documentation我不明白我应该如何写查询谓词。

谁能帮帮我?

查询谓词遵循 json 响应的结构。使用 () 方括号访问嵌套字段。

试试这个

ancestors(id = "idb27086d2-33f2-43c3-aad1-4c01b2b9a886")