'Elasticsearch - what the best way to find all indices between two dates for rotating index set up using Java client
Our set up in ES ( 7.x) is to rotate indexes every day in format indexName-yyyy-MM-dd
I'm trying to find the best way to predict the indexes between two days so I can include them in a search request in Java Rest high-level client
As the guide indicates "Limiting the number of indices that are searched reduces the load on the cluster and improves execution performance"
So instead of searching for all indexes indexName-* I'm trying to narrow the index list.
I do have a solution for iterating no of days between From and To and constructing an index list.
for (int j=days; j>=0; i--) {
/* generate indexnames
* ( "indexName-" + dateFormatter.format(To.minusDays(day));
*/
}
however, I'm worried about including such a large list if no of days are bigger( maybe what I have is good enough) also trying to avoid a second query ( i can make a query and find out what indexes are available. but not that efficient)
As I know ES will accept indexName-yyyy-MM-* ( wildcards, instead of laying out all the days)
just checking her for any good ideas, suggestions. Thanks in advance
Solution 1:[1]
I settled with what I already have with some toleranc
for (int j=days; j>=0; i--) {
/* generate indexnames
* ( "indexName-" + dateFormatter.format(To.minusDays(day));
*/
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | csf |
