Delete API: Allow to set _parent on it (will simply set the routing value), closes #742.

This commit is contained in:
kimchy 2011-03-02 22:14:49 +02:00
parent 655cbb9440
commit 4631df9d01
3 changed files with 13 additions and 1 deletions

View File

@ -141,7 +141,7 @@ public class BulkRequest implements ActionRequest {
}
if ("delete".equals(action)) {
add(new DeleteRequest(index, type, id).routing(routing));
add(new DeleteRequest(index, type, id).parent(parent).routing(routing));
} else {
nextMarker = findNextMarker(marker, from, data, length);
if (nextMarker == -1) {

View File

@ -167,6 +167,17 @@ public class DeleteRequest extends ShardReplicationOperationRequest {
return this;
}
/**
* Sets the parent id of this document. Will simply set the routing to this value, as it is only
* used for routing with delete requests.
*/
public DeleteRequest parent(String parent) {
if (routing == null) {
routing = parent;
}
return this;
}
/**
* Controls the shard routing of the request. Using this value to hash the shard
* and not the id.

View File

@ -50,6 +50,7 @@ public class RestDeleteAction extends BaseRestHandler {
@Override public void handleRequest(final RestRequest request, final RestChannel channel) {
DeleteRequest deleteRequest = new DeleteRequest(request.param("index"), request.param("type"), request.param("id"));
deleteRequest.parent(request.param("parent"));
deleteRequest.routing(request.param("routing"));
deleteRequest.timeout(request.paramAsTime("timeout", DeleteRequest.DEFAULT_TIMEOUT));
deleteRequest.refresh(request.paramAsBoolean("refresh", deleteRequest.refresh()));