Skip to content

Commit

Permalink
Delete API: Allow to set _parent on it (will simply set the routing v…
Browse files Browse the repository at this point in the history
…alue), closes elastic#742.
  • Loading branch information
kimchy committed Mar 2, 2011
1 parent 594cae1 commit 69baf39
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public BulkRequest add(byte[] data, int from, int length, boolean contentUnsafe)
}

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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,17 @@ public DeleteRequest timeout(TimeValue timeout) {
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down

0 comments on commit 69baf39

Please sign in to comment.