Dynamic index name in DSL

I have created indexes based on year and month.
For ex: idx202001, idx202002,...
In the dashboard, based on the time filter selected, I would like to query particular indices only.

Like

{
"query": {
"match": {
"_index": {
"query": "idx2020*",
"type": "phrase"
}
}
}
}

Is it possible to dynamically calculate the index names based on the time filter selected?

Thanks.

No, but it's not something you should worry about.
Elasticsearch will only query the indices it needs when you run these sorts of queries.

1 Like