Reputation: 23277
I'm trying to send this request using Java API:
curl -XPUT 'http://localhost:9201/living/_alias/living_team' -d '
{
"routing": "living_team",
"filter": {
"term": {
"user": "living_team" //user property must exists
}
}
}'
Up to now, I've not been able to figure out how exactly build the Java request:
this.elasticsearchResources.getElasticsearchClient()
.admin()
.indices()
.prepareAliases()
.addAlias(
ElasticsearchRepository.ELASTICSEARCH_INDEX,
alias,
QueryBuilders.termQuery("user", alias);
This line only creates an ADD ALIAS request with a filter, nevertheless I don't know how to set routing path...
How could I set the routing path up on request?
Upvotes: 0
Views: 1774
Reputation: 116
You mean how to set "http://localhost:9201/living/_alias/living_team" on your request?
PS. I wrote this as an answer cause i cannot comment yet.
Edited:
Hope this can help you
IndicesAliasesRequest request = new IndicesAliasesRequest();
request.addAliasAction(new AliasAction(AliasAction.Type.ADD).alias("the_alias").index(index).searchRouting("the_search_routing").indexRouting("the_index_routing"));
IndicesAliasesResponse response = elasticsearchClient.admin().indices().aliases(request).get();
Upvotes: 1