在Elasticsearch中,此语句的查询可以是什么

af7jpaap  于 2022-12-03  发布在  ElasticSearch
关注(0)|答案(1)|浏览(137)

我尝试在elasticsearch语句中使用此查询:

(ip=xx.xx.xx.xx and status="running") or (ip=xx.xx.xx.xx and status="running")

有谁能告诉我如何用ElasticSearch查询来写这个吗?

pxiryf3j

pxiryf3j1#

阅读关于Bool Queries
请尝试以下查询:

{
  "query": {
    "bool": {
      "minimum_should_match": 1, 
      "should": [
        {
          "bool": {
            "must": [
              {
                "term": {
                  "ip": {
                    "value": "xx.xx.xx.xx"
                  }
                }
              },
              {
                "term": {
                  "status": {
                    "value": "running"
                  }
                }
              }
            ]
          }
        },
         {
          "bool": {
            "must": [
              {
                "term": {
                  "ip": {
                    "value": "bb.bb.bb.bb"
                  }
                }
              },
              {
                "term": {
                  "status": {
                    "value": "running"
                  }
                }
              }
            ]
          }
        }
      ]
    }
  }
}

相关问题