如何在Elastic Search 8.9 v中获取带有must match子句的文档

问题描述 投票:0回答:1
{
    "size": 0,
    "query": {
        "bool": {
            "must": [
                {
                    "match": {
                        "web_code": "P" // how to write multiple codes here
                    }
                }
            ]
        }
    }
 }

以上对于单个值来说工作得很好。如何使用 Must 语法获取多个 Web 代码..?

elasticsearch elastic-stack elasticsearch-5 elasticsearch-aggregation elasticsearch-dsl
1个回答
0
投票

您可以使用

terms
查询而不是
match
来完成此操作:

{
    "size": 0,
    "query": {
        "bool": {
            "must": [
                {
                    "terms": {
                        "web_code": ["P", "R", "S", "T"]
                    }
                }
            ]
        }
    }
 }
© www.soinside.com 2019 - 2024. All rights reserved.