【问题标题】:How to fetch all the latest documents using elastic search based on timestamp [closed]如何使用基于时间戳的弹性搜索获取所有最新文档 [关闭]
【发布时间】:2020-09-03 12:49:34
【问题描述】:

我是弹性搜索的新手,我需要使用“get”获取新受影响或最近 1 天的文档并插入到 postgres 表中

我尝试使用搜索并给出 now() - 1440m 这是获取整个记录,我只需要最近的记录

【问题讨论】:

  • GET _search {...} 调用中的内容是什么?
  • 我给了_search?sort=create_date:now-1440m

标签: postgresql elasticsearch pycurl


【解决方案1】:

在向/<index-name>/_search 发出请求时尝试使用此请求有效负载:

{
  "query": {
    "bool": {
      "filter": [
        {
          "range": {
              "create_date": {
                  "gte": "now-1d"
              }
          }
        }
      ]
    }
  }
}

无需使用任何sorting 您在评论中表示的方式。只需使用此作为有效负载向普通的/_search 端点发出请求。

【讨论】:

    猜你喜欢
    • 2015-05-24
    • 1970-01-01
    • 2017-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-20
    • 1970-01-01
    相关资源
    最近更新 更多