弹性搜索计数查询

Elastic search count query

我正在尝试查找给定时间段内出现的特定模式。 我没有得到带有时间参数的 Query 1 模式的计数,但可以与 Query 2 一起使用。 如果 Query 1.

有任何问题,你能问一下吗?

查询 1:

GET/_count?pretty{
  "query": {
    "bool": {
      "must": {
        "query_string": {
          "query": "Stopping PSB: start the yum-updateonboot deamon..."
        }
      },
      "filter": {
        "range": {
          "@timestamp": {
            "gt": "now-1d"
          }
        }
      }
    }
  }
}'  Result: {   **"count" : 0,**   "_shards" : {     "total" : 2287,     "successful" : 2287,     "skipped" : 0,     "failed" : 0   } 
查询 2:
GET/_count?pretty{
  "query": {
    "bool": {
      "must": {
        "query_string": {
          "query": "Stopping PSB: start the yum-updateonboot deamon..."
        }
      }
    }
  }
}Result: {
  "count": 280483,
  "_shards": {
    "total": 2287,
    "successful": 2287,
    "skipped": 0,
    "failed": 0
  }

date math with days is somewhat confusing.

使用时间:

{
  "range":{
    "@timestamp":{
      "gt":"now-24h"
    }
  }
}

gte 而不是 gt:

{
  "range":{
    "@timestamp":{
      "gte":"now-1d"
    }
  }
}

更新

使用timestamp代替@timestamp

{
  "query": {
    "bool": {
      "must": {
        "query_string": {
          "query": "Stopping PSB: start the yum-updateonboot deamon..."
        }
      },
      "filter": {
        "range": {
          "timestamp": {
            "gt": "now-1d"
          }
        }
      }
    }
  }
}

由于 this and this.