当前位置: 动力学知识库 > 问答 > 编程问答 >

sense - Get last document from ElasticSearch

问题描述:

so I have an elastic search index and I am sending docs to it attached with a timestamp. I am wondering if there is a way to extract the last document based on the time stamp. I.e. say to elastic give me the doc with the last time.

Thanks.

网友答案:

Yes, you can simply request one single document (size: 1) and sorted by decreasing timestamp

POST index/_search
{
   "size": 1,
   "sort": { "timestamp": "desc"},
   "query": {
      "match_all": {}
   }
}
分享给朋友:
您可能感兴趣的文章:
随机阅读: