Hi,
There was a similar question in the forums years ago, but it didn't get answered so I thought I'd ask and see if maybe something has changed or there is a specific way to do this.
I have an elastic query that gets a document by ID. I want to retrieve the next document in the index based on a sorted date field that also stores the time.
Below is my current query which doesn't work obviously because it is returning always document _id = 48. I am not sure of the syntax needed to get the next document based on the date_posted field taking into account the date posted of the current document _id 48.
{
"size" : 1,
"query": {
"bool": {
"filter": [
{ "term": { "_id":"48" }}
]
}
},
"sort": [
{
"date_posted": {
"order": "asc"
}
}
]
}