# How to get latest document in multiple indices

**URL:** https://discuss.elastic.co/t/how-to-get-latest-document-in-multiple-indices/186014
**Category:** Elasticsearch
**Created:** [June 17, 2019, 8:02am UTC](https://discuss.elastic.co/t/how-to-get-latest-document-in-multiple-indices/186014 "2019-06-17T08:02:17Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![himberjack](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/himberjack/32/48211_2.png) [@himberjack](https://discuss.elastic.co/u/himberjack)
#### Post date: [June 17, 2019, 8:02am UTC](https://discuss.elastic.co/t/how-to-get-latest-document-in-multiple-indices/186014/1 "2019-06-17T08:02:17Z")

</div>

We have several document types across several indices (each type in its own index).  
We are querying all indices which works great.  
However, we want to be able to do top\_hits and to get the latest document but from specific type, not the latest in the whole query.  
How can that be achieved?

Many thanks

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [June 17, 2019, 12:25pm UTC](https://discuss.elastic.co/t/how-to-get-latest-document-in-multiple-indices/186014/2 "2019-06-17T12:25:42Z")

</div>

Hey,

have you thought about using a [multi search](https://www.elastic.co/guide/en/elasticsearch/reference/7.1/search-multi-search.html) to get a single result for each index or are you index specified somewhat dynamic?

--Alex

---

<div class="post-metadata">

### Author: ![himberjack](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/himberjack/32/48211_2.png) [@himberjack](https://discuss.elastic.co/u/himberjack)
#### Post date: [June 17, 2019, 12:37pm UTC](https://discuss.elastic.co/t/how-to-get-latest-document-in-multiple-indices/186014/3 "2019-06-17T12:37:17Z")

</div>

it is not a matter of multiple queries- I can do it manually as well. I want to get it in one query. My index is {type}-yyyy-mm-dd

---

<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 15, 2019, 12:37pm UTC](https://discuss.elastic.co/t/how-to-get-latest-document-in-multiple-indices/186014/4 "2019-07-15T12:37:17Z")

</div>

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