Elasticsearch index name from template variable

We have an elasticsearch database with 2 indexes which contain instrument data. The schema of the documents within the 2 indexes are identical and the index names only differ in a sub-string which identifies the instrument.
As an example: There are 2 indexes called “grm-cps-hk” and “fm-cps-hk” with “grm” and “fm” being the name of the instrument.
We have created a dashboard with several panels using a elasticsearch data source set to the index “grm-cps-hk”. Now we would like to use a template variable to select the instrument. As far as I know, the index and time field must be specified in the data source settings and therefore a have 1 data source per index.
Is there a way I can use a template variable to determine the index name (e.g. $instrument-cps-hk) maybe by not specifying the index name in the data source settings but later in the lucene query?

After more googling and testing I found the solution myself.
In the data source settings I’ve set the index name to * and in the graph panels I use the lucene query $instrument-cps-hk with “instrument” being a custom template variable with the values “grm” and “fm”.