# Need to get Elastic Search current highest id

**URL:** <https://discuss.elastic.co/t/need-to-get-elastic-search-current-highest-id/17038>\
**Category:** Elasticsearch\
**Created:** [April 16, 2014, 5:36am UTC](https://discuss.elastic.co/t/need-to-get-elastic-search-current-highest-id/17038 "2014-04-16T05:36:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phani\_Nadiminti](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/phani_nadiminti/32/45381_2.png) [@Phani\_Nadiminti](https://discuss.elastic.co/u/Phani_Nadiminti)\
**Post date:** [April 16, 2014, 5:36am UTC](https://discuss.elastic.co/t/need-to-get-elastic-search-current-highest-id/17038/1 "2014-04-16T05:36:58Z")

</div>

Hi All,

I am new to elastic search. I am working on river jdbc mysql concepts I  
have a scenario like I need to get highest value for field "id" that is  
inserted in to elastic search.please suggest me how to build this query to  
get highest value for id inserted.

Thanks & Regards,  
phani.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/cafd8ae1-aaa8-4e97-ae75-349c9d59c84c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/cafd8ae1-aaa8-4e97-ae75-349c9d59c84c%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Phani\_Nadiminti](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/phani_nadiminti/32/45381_2.png) [@Phani\_Nadiminti](https://discuss.elastic.co/u/Phani_Nadiminti)\
**Post date:** [September 28, 2015, 12:39pm UTC](https://discuss.elastic.co/t/need-to-get-elastic-search-current-highest-id/17038/2 "2015-09-28T12:39:44Z")

</div>

Hi,

I got the solution to get max id .

GET /index/type/\_search  
{  
"aggs" : {  
"max\_id" : { "max" : { "field" : "id" } }  
}  
}

Thanks  
phani

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:47pm UTC](https://discuss.elastic.co/t/need-to-get-elastic-search-current-highest-id/17038/3 "2017-07-05T23:47:47Z")

</div>


