多个必须在 ElasticSearch 上查询时间范围

multiple must query on ElasticSeach with time range

我想使用多个 must 查询,但出现以下错误。重复键“必须”语法错误。当我将范围添加到上面的 must 块时,它也没有给出正确的结果。

我要的是简单的:如果word1和word2都在日志中,我想抓取它们。

{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "message": "word1"
          }
        },
        {
          "match": {
            "message": "word2"
          }
        }
      ],
      "must": [
        {
          "range": {
            "date_time": {
              "gte": "now-15m"
            }
          }
        }
      ],
      "minimum_should_match": 1
    }
  }
}

你好试试这样的查询:

GET .yourindex/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "message": "word1"
          }
        },
        {
          "match": {
            "message": "word2"
          }
        },
        {
          "range": {
            "date_time": {
              "gte": "now-15hm"
            }
          }
        }
      ]
    }
  }
}