如何将“必须”和“应该”与AND条件结合在一起?

I need to return documents from ES that satisfy these 2 conditions: at least one of conditionIds in the should clause should match the conditionId property of documents AND at least one of the categoryIds should match.

我尝试了此查询,但这不起作用:

{
"query": {
"bool": {
"should": [
{
"match": {
"conditionIds": "5e24b2f02bd0d76df4615c82"
}
},
{
"match": {
"conditionIds": "5e24b2f02bd0d76df4615c82"
}
},
],
"filter": [
{
"query_string": {
"default_field": "name",
"query": "*"
}
}
],
"must": [
{
"match": {
"categoryIds": “fc57hj5-0bx-4sha-aw7u-c11cd32eec2a"
}
},
{
"match": {
"categoryIds": "d2c5a505-01bb-41ba-ad7e-c11cd32eec2a"
}
}
]
}
}
}

和我的文档架构:

                "conditionIds": [
                    "5e24b2f02bd0d76df4615c81"
                ],
                "createdAt": "2020-05-08T19:07:11.756Z",
                "categoryIds": [
                    "7b913ed0-54e0-4857-b114-92f65631b6a6"
                ],
                "minPrice": 71.47,
                "locations": [
                    {
                        "continent": "GLOBAL",
                        "lon": 0,
                        "lat": 0
                    }
                ],
                "id": "c64d03d6-4248-416c-bc07-c42b50548e3b",
                "maxPrice": 71.47,
                "statusIds": [
                    "5e24b2f02bd0d76df4615c81"
                ],
                "childrenCount": 1,
                "updatedAt": "2020-05-08T19:07:11.756Z"
            }
评论