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