Alias with filter not explicit at indexing-->not in alias?


(sandro) #1

So I have an index with the following alias defined:
bod = { "routing": "goHere", "filter": { "bool": { "must": [ { "term": {"algo": "algo1"} }, { "term": {"client": "MyClient"} } ] } }}

And then send it to ES from python via:
es.indices.put_alias(index=INDEX_NAME, name="CoolAliasName", body=bod)

This all works fine and as expected if I send a new document to index to the alias, i.e (curl-exple since I guess more people familiar with this rather than python).:
curl -XPOST 'localhost:9200/CoolAliasName/algos/_index' -d '{"client":"MyClient",[...],"algo":"algo1"}'

Then I find this documen with

curl -XGET 'localhost:9200/CoolAliasName/_search

But If I change the index operation to (index change from CollAliasName to master_index):
curl -XPOST 'localhost:9200/master_index/algos/_index' -d '{"client":"MyClient",[...],"algo":"algo1"}'

then the document is indexed, but I cant find it in the alias "CoolAliasName" even if the conditions for being there are satisfied. Is it because algo==algo1 and client==MyClient satisfy the alias def, but I do not specify the routing?


(sandro) #2

Ok did some more tries, added routing value and removed the _index since ES saw it as an ID, forgot that with curl and POST it is not needed (and would be op_type-param anyway).
Setting the routing when indexing does the job.


(system) #3