How to have Range and Match query in one elastic search query using python?

后端 未结 1 1268
日久生厌
日久生厌 2020-12-21 23:52

I have to find the matching documents which have the string, for example: \"sky\", within some \"key\" range. When I write separate match and range query, I get the output f

相关标签:
1条回答
  • 2020-12-22 00:51

    You need to do it like this using a bool/must query

    res = es.search(index="dummy", body={
      "from": 0,
      "size": 0,
      "query": {
        "bool": {
          "must": [
            {
              "range": {
                "key": {
                  "gte": "1000"
                }
              }
            },
            {
              "match": {
                "word": "sky"
              }
            }
          ]
        }
      }
    })
    
    0 讨论(0)
提交回复
热议问题