0

How to retrieve index name in elastic search based on some given aliases names. Example: Index_name: test Aliases names: a1,a2,a3 Index_name: test2 Aliases name: a1,a3 Index_name: test3 Aliases name: a1 retrieve the index name which has a1,a2,a3 in its alias names. expected from above example: test

Akib Ali
  • 23
  • 1
  • 7

1 Answers1

0

GET /alias_name returns a json with all the indices using the alias.

For this use case, you can try something like below.

curl -XGET <ES_URL>/_cat/aliases/a1,a2,a3 2>/dev/null | cut -d ' ' -f2 | uniq -c | grep "^[[:space:]]\+3"

The command prints only indices with all '3' aliases.

harishkb
  • 406
  • 3
  • 7
  • yes you are right. but in my case index has more than one alias name and i want all the indices which contains all the aliases names what i search . In my above example if i want to get all the indices which has a1,a2,a3 (in AND condition) i should get only “test” index name – Akib Ali Feb 14 '18 at 14:51
  • We are not directly using elasticsearch by curl. I am using java high level client so i want a api with some query. – Akib Ali Feb 14 '18 at 17:31
  • could so please suggest something – Akib Ali Feb 14 '18 at 17:32
  • I can't think of an api that can do this. You might want to raise a ticket in elastic support for advice from the experts. – harishkb Feb 15 '18 at 10:07