上QQ阅读APP看书,第一时间看更新
There's more...
Aliases can also be used to define a filter and routing parameter.
Filters are automatically added to the query to filter out data. Routing by using an alias allows us to control which shards to hit during searching and indexing.
An example of this call is as follows:
POST /myindex/_aliases/user1alias
{
"filter": {
"term": {
"user": "user_1"
}
},
"search_routing": "1,2",
"index_routing": "2"
}
In this case, we are adding a new alias, user1alias, to a myindex index, and are also adding the following:
- A filter to select only documents that match a field user with a user_1 term.
- A list and a routing key to select the shards to be used during a search.
- A routing key to be used during indexing. The routing value is used to modify the destination shard of the document.
The search_routing parameter allows multi-value routing keys. The index_routing parameter is single-value only.