Doubt about alias


(Fabio Ebner) #1

It`s possible to create one alias to more than one index??

Example:

I have one index for each state in the world, but I wanna create one alias for country,

So if I search in Brazil he will search in +/- 28 index.

tks


(sandro) #2

FRom the docs indices alias:

curl -XPOST 'http://localhost:9200/_aliases' -d ' { "actions" : [ { "add" : { "index" : "test1", "alias" : "alias1" } }, { "add" : { "index" : "test2", "alias" : "alias1" } } ] }'

In you case you just add a filter on country eg.
curl -XPOST 'http://localhost:9200/_aliases' -d ' { "actions" : [ { "add" : { "index" : "test1", "alias" : "brazil" ,"filter" : { "term" : { "country" : "brazil" }} }, { "add" : { "index" : "test2", "alias" : "brazil" ,"filter" : { "term" : { "country" : "brazil" }} } [...]


(system) #3