# Get the latest index of a certain form in elasticsearch

**URL:** https://discuss.elastic.co/t/get-the-latest-index-of-a-certain-form-in-elasticsearch/313379
**Category:** Elasticsearch
**Created:** [August 31, 2022, 4:31pm UTC](https://discuss.elastic.co/t/get-the-latest-index-of-a-certain-form-in-elasticsearch/313379 "2022-08-31T16:31:15Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![kosmylo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kosmylo/32/99660_2.png) [@kosmylo](https://discuss.elastic.co/u/kosmylo)
#### Post date: [August 31, 2022, 4:31pm UTC](https://discuss.elastic.co/t/get-the-latest-index-of-a-certain-form-in-elasticsearch/313379/1 "2022-08-31T16:31:15Z")

</div>

I am periodically training an anomaly detection model and I am saving it in `elasticsearch` index of the form `'anomaly_detection_model-' + date_model_trained`. This means that I am ending up with indices of the form: `anomaly_detection_model-31.08.2022`, `anomaly_detection_model-29.08.2022`, `anomaly_detection_model-27.08.2022`, etc. I need to be able to get access to the latest model at real-time in order to make the predictions without knowing what is the date that this model was trained. Do you have any ideas of how this could be possible?

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [August 31, 2022, 9:22pm UTC](https://discuss.elastic.co/t/get-the-latest-index-of-a-certain-form-in-elasticsearch/313379/2 "2022-08-31T21:22:15Z")

</div>

`GET /_cat/indices/anomaly_detection_model-*?pretty&s=creation.date:desc` should do it.

---

<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: [September 28, 2022, 9:22pm UTC](https://discuss.elastic.co/t/get-the-latest-index-of-a-certain-form-in-elasticsearch/313379/3 "2022-09-28T21:22:42Z")

</div>

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