I am using an alias name when writing data using Bulk Api. I have 2 questions:
Can I get the index name after writing data using the alias name maybe as part of the response? Can I improve performance if I send search queries on specific indexes instead to search on all indexes of the same alias?
CodePudding user response:
You can provide the multiple index names while searching the data, if you are using alias
and it has multiple indices by default it would search on all the indices, but if you want to filter it based on a few indices in your alias
, that is also possible based on the fields in the underlying indices.
You can read the Filter-based aliases to limit access to data section in this blog on how to achieve it, as it queries fewer indices and less data, search performance would be better.
Also alias
can have only single writable index, and name of that you can get as part of _cat/alias?v
api response as well, which shows which is the write_index
for the alias, you can see the sample output here
CodePudding user response:
If you're using an alias name for writes, that alias can only point to a single index which you're going to receive back in the bulk response
For instance, if test_alias
is an alias to the test
index, then when sending this bulk command:
POST test_alias/_doc/_bulk
{"index":{}}
{"foo": "bar"}
You will receive this response:
{
"index" : {
"_index" : "test", <---- here is the real index name
"_type" : "_doc",
"_id" : "WtcviYABdf6lG9Jldg0d",
"_version" : 1,
"result" : "created",
"_shards" : {
"total" : 2,
"successful" : 2,
"failed" : 0
},
"_seq_no" : 0,
"_primary_term" : 1,
"status" : 201
}
}
Common sense has it that searching on a single index is always faster than searching on an alias spanning several indexes, but if the alias only spans a single index, then there's no difference.