es中must和should的用法

GET gather-034-20171225/_search
{
  "query": {
    "bool": {
      "must": [
        {"range": {
          "recive_time": {
            "gte": "2017-12-25T01:00:00.000Z",
            "lte": "2017-12-25T02:10:00.000Z"
          }
        }},
        {
          "bool": {
            "should": [
              {"range": {
                "live_delay": {
                  "gte": 1500
                }
              }},
              {
                "range": {
                  "stream_break_count.keyword": {
                    "gte": 1
                  }
                }
              }
            ]
          }
        }
      ]
    }
  }
}
这个中,must的两个条件都必须满足,should中的两个条件至少满足一个就可以。
GET /ssa_envents*/nsec/_search
{
  "query": {
    "bool": {
      "must": [
        {"match": {
          "dPosition": "北京市"
        }},
        {
          "match": {
            "program": "FILTER"
          }
        }
      ]
    }
  }
}

猜你喜欢

转载自blog.csdn.net/wyqwilliam/article/details/84024182
今日推荐