Regexp in searching for aliases


(Mohammad Hashemian) #1

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


(Nik Everett) #2

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


(Mohammad Hashemian) #3

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


(Mohammad Hashemian) #4

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


(Mayya Sharipova) #5

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*'


(Mohammad Hashemian) #6

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


(system) #7

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