As you can see we have 2 documents per index, and a empty index for the data that we would like to reindex to:
123456
$ curl -XGET http://127.0.0.1:9200/_cat/indices?v
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open animals-2017.11.20 AxRYUfNpQ5ev2mdZf0bYrw 5120 8.9kb 8.9kb
green open animals-2017.11 1T6TkYWwRuerIZ5_np1B0w 5000 1.5kb 1.5kb
yellow open animals-2017.11.22 fCdaRyBZRiWyQ3tZLhdBrw 5120 8.9kb 8.9kb
yellow open animals-2017.11.21 4Ei9zMDITHy1dI8lIzfjjA 5120 8.9kb 8.9kb
Reindex the Data to our Monthly Index:
We will define our query to match all the indexes that has the data and reindex to our new index animals-2017.11:
$ curl -XGET http://127.0.0.1:9200/_cat/indices?v
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open animals-2017.11.20 AxRYUfNpQ5ev2mdZf0bYrw 5120 8.9kb 8.9kb
green open animals-2017.11 1T6TkYWwRuerIZ5_np1B0w 5060 20.2kb 20.2kb
yellow open animals-2017.11.22 fCdaRyBZRiWyQ3tZLhdBrw 5120 8.9kb 8.9kb
yellow open animals-2017.11.21 4Ei9zMDITHy1dI8lIzfjjA 5120 8.9kb 8.9kb
Delete the Old Indexes:
As your data is now reindexed, we can safely remove our old indexes:
$ curl -XGET http://127.0.0.1:9200/_cat/indices?v
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open animals-2017.11 1T6TkYWwRuerIZ5_np1B0w 5060 20.2kb 20.2kb