I used "implicit router" when created my collection and I used SolrJ to access Solr. In this mode, I do my query request by providing a param named route。But, if I want to call CloudSolrServer's deleteByQuery()
method,how can I set this parameter? I just only want to pass my request to the right shard, not all shards, I don't know how to get it。
Asked
Active
Viewed 344 times
0

Brian Tompsett - 汤莱恩
- 5,753
- 72
- 57
- 129

westernlake
- 31
- 2
1 Answers
2
Luckily,I have founded the answer. When I was reading CloudSolrServer's source code, I founded the following method:
public UpdateResponse deleteByQuery(String query) throws SolrServerException, IOException {
return new UpdateRequest().deleteByQuery( query ).process( this );
}
And the UpdateResponse class has a method setParam().
So, the final code is as follows:
UpdateRequest deleteRequest = new UpdateRequest();
deleteRequest.setParam("_route_", shardId);
UpdateResponse reponse = deleteRequest.deleteByQuery(delQuery).process(cloudSolrServer_);
I have tried it and found no problems.

CDspace
- 2,639
- 18
- 30
- 36

westernlake
- 31
- 2