弹性搜索计数查询

库马尔

我试图在给定的时间内找到特定模式的出现。我没有得到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
  }
乔·索罗辛

带有ays日期数学d有点令人困惑

使用任一小时:

{
  "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"
          }
        }
      }
    }
  }
}

由于这个这个

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章