How Can i get max id of indexed documents

I am new to elastic search. I indexed few of documents and i want to find the max id which ever inserted across the documents.

My URL something like ":/books/dramabooks/_search?size=0"
{
"aggs" : {
"max_id" : { "max" : { "field" : "id" } }
}
} --POST URL

Response:
{"took":75,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":5,"max_score":0.0,"hits":[]},"aggregations":{"max_id":{"value":null}}}

Note:request returning max_id value as null.

Could you please provide right query that should return maximum value of id.

Thanks in advance.

Hey!

ID's are usually a SHA or UUID! There is no pattern of numerical ascendancy/descendancy to them to find out the max of, unless you are overriding the ID upon insertion!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.