Regexp in searching for aliases

Hi,

I have multiple indices and each index has multiple aliases. Is there a way to search for aliases using regexp?

For example, I can use this query:

curl -XGET 'localhost:9200/_alias/2016*?pretty'

to get all aliases starting with 2016, but if I want to get all aliases starting with 2016 and 2017 (but not 2015 or 2018), how could I achieve this? I tried different variations of this:

curl -XGET 'localhost:9200/_alias/2016*|2017*?pretty'

but it did not work.

Thanks a lot

Regular expressions aren't supported. You can only use the glob style thing. This is what implements it:

1 Like

I suspected that's the case. Do you know any other way to query aliases with one request (like search)? I can send multiple requests (e.g. one for 2016*, one for 2017*, etc) but I hoped to find a better way.

Thanks

I actually ended up using the Client API for JavaScript for this. That allows using a comma-separated list of alias names. It still does not support regexp, as you said @nik9000, but it allows using "2016*,2017*" which serves my purpose.

Thanks

1 Like

If you want to search multiple aliases' patterns using Elastic http api, you can also try to separate them using comma. For example:

curl -XGET 'localhost:9200/_alias/2016*,2017*'

1 Like

Ah, yes, you are right @mayya. That worked. Thanks.

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