Reverted commit: 20f7be3
This commit is contained in:
parent
d78159fee1
commit
75713f4190
|
@ -200,6 +200,8 @@ including:
|
|||
`routing`:: Sets the routing that will be used to route the
|
||||
document to the relevant shard.
|
||||
|
||||
`parent`:: Simply sets the routing.
|
||||
|
||||
`timeout`:: Timeout waiting for a shard to become available.
|
||||
|
||||
`consistency`:: The write consistency of the index/delete operation.
|
||||
|
|
|
@ -153,7 +153,7 @@ The `parent` parameter has been removed from the update request. Before 2.x it j
|
|||
`routing` setting should be used instead. The `parent` setting was confusing, because it had the impression that the parent
|
||||
a child documents points to can be changed but this is not true.
|
||||
|
||||
=== Delete by query
|
||||
==== Delete by query
|
||||
|
||||
The meaning of the `_shards` headers in the delete by query response has changed. Before version 2.0 the `total`,
|
||||
`successful` and `failed` fields in the header are based on the number of primary shards. The failures on replica
|
||||
|
|
|
@ -36,6 +36,10 @@
|
|||
"type": "string",
|
||||
"description": "The script language (default: groovy)"
|
||||
},
|
||||
"parent": {
|
||||
"type": "string",
|
||||
"description": "ID of the parent document"
|
||||
},
|
||||
"refresh": {
|
||||
"type": "boolean",
|
||||
"description": "Refresh the index after performing the operation"
|
||||
|
|
|
@ -29,10 +29,10 @@ setup:
|
|||
index: test_1
|
||||
type: test
|
||||
id: 1
|
||||
routing: 5
|
||||
parent: 5
|
||||
body:
|
||||
doc: { foo: baz }
|
||||
upsert: { foo: bar, _parent: 5 }
|
||||
upsert: { foo: bar }
|
||||
|
||||
- do:
|
||||
get:
|
||||
|
@ -50,7 +50,7 @@ setup:
|
|||
index: test_1
|
||||
type: test
|
||||
id: 1
|
||||
routing: 5
|
||||
parent: 5
|
||||
fields: foo
|
||||
body:
|
||||
doc: { foo: baz }
|
||||
|
|
|
@ -21,10 +21,11 @@
|
|||
index: test_1
|
||||
type: test
|
||||
id: 1
|
||||
parent: 5
|
||||
routing: 4
|
||||
body:
|
||||
doc: { foo: baz }
|
||||
upsert: { foo: bar, _parent: 5 }
|
||||
upsert: { foo: bar }
|
||||
|
||||
- do:
|
||||
get:
|
||||
|
@ -44,7 +45,7 @@
|
|||
index: test_1
|
||||
type: test
|
||||
id: 1
|
||||
routing: 5
|
||||
parent: 5
|
||||
body:
|
||||
doc: { foo: baz }
|
||||
|
||||
|
@ -53,6 +54,7 @@
|
|||
index: test_1
|
||||
type: test
|
||||
id: 1
|
||||
parent: 5
|
||||
routing: 4
|
||||
fields: foo
|
||||
body:
|
||||
|
|
|
@ -351,13 +351,14 @@ public class BulkRequest extends ActionRequest<BulkRequest> implements Composite
|
|||
.create(true)
|
||||
.source(data.slice(from, nextMarker - from), contentUnsafe), payload);
|
||||
} else if ("update".equals(action)) {
|
||||
UpdateRequest updateRequest = new UpdateRequest(index, type, id).routing(routing).retryOnConflict(retryOnConflict)
|
||||
UpdateRequest updateRequest = new UpdateRequest(index, type, id).routing(routing).parent(parent).retryOnConflict(retryOnConflict)
|
||||
.version(version).versionType(versionType)
|
||||
.source(data.slice(from, nextMarker - from));
|
||||
|
||||
IndexRequest upsertRequest = updateRequest.upsertRequest();
|
||||
if (upsertRequest != null) {
|
||||
upsertRequest.routing(routing);
|
||||
upsertRequest.parent(parent); // order is important, set it after routing, so it will set the routing
|
||||
upsertRequest.timestamp(timestamp);
|
||||
upsertRequest.ttl(ttl);
|
||||
upsertRequest.version(version);
|
||||
|
@ -366,6 +367,7 @@ public class BulkRequest extends ActionRequest<BulkRequest> implements Composite
|
|||
IndexRequest doc = updateRequest.doc();
|
||||
if (doc != null) {
|
||||
doc.routing(routing);
|
||||
doc.parent(parent); // order is important, set it after routing, so it will set the routing
|
||||
doc.timestamp(timestamp);
|
||||
doc.ttl(ttl);
|
||||
doc.version(version);
|
||||
|
|
|
@ -174,6 +174,17 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
|||
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 UpdateRequest 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.
|
||||
|
|
|
@ -69,6 +69,11 @@ public class UpdateRequestBuilder extends InstanceShardOperationRequestBuilder<U
|
|||
return this;
|
||||
}
|
||||
|
||||
public UpdateRequestBuilder setParent(String parent) {
|
||||
request.parent(parent);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The script to execute. Note, make sure not to send different script each times and instead
|
||||
* use script params if possible with the same (automatically compiled) script.
|
||||
|
|
|
@ -57,6 +57,7 @@ public class RestUpdateAction extends BaseRestHandler {
|
|||
UpdateRequest updateRequest = new UpdateRequest(request.param("index"), request.param("type"), request.param("id"));
|
||||
updateRequest.listenerThreaded(false);
|
||||
updateRequest.routing(request.param("routing"));
|
||||
updateRequest.parent(request.param("parent")); // order is important, set it after routing, so it will set the routing
|
||||
updateRequest.timeout(request.paramAsTime("timeout", updateRequest.timeout()));
|
||||
updateRequest.refresh(request.paramAsBoolean("refresh", updateRequest.refresh()));
|
||||
String consistencyLevel = request.param("consistency");
|
||||
|
|
|
@ -427,8 +427,8 @@ public class BulkTests extends ElasticsearchIntegrationTest {
|
|||
byte[] addParent = new BytesArray("{\"index\" : { \"_index\" : \"test\", \"_type\" : \"parent\", \"_id\" : \"parent1\"}}\n" +
|
||||
"{\"field1\" : \"value1\"}\n").array();
|
||||
|
||||
byte[] addChild = new BytesArray("{ \"update\" : { \"_index\" : \"test\", \"_type\" : \"child\", \"_id\" : \"child1\", \"routing\" : \"parent1\"}}\n" +
|
||||
"{\"doc\" : { \"field1\" : \"value1\", \"_parent\" : \"parent1\"}, \"doc_as_upsert\" : \"true\"}\n").array();
|
||||
byte[] addChild = new BytesArray("{ \"update\" : { \"_index\" : \"test\", \"_type\" : \"child\", \"_id\" : \"child1\", \"parent\" : \"parent1\"}}\n" +
|
||||
"{\"doc\" : { \"field1\" : \"value1\"}, \"doc_as_upsert\" : \"true\"}\n").array();
|
||||
|
||||
builder.add(addParent, 0, addParent.length, false);
|
||||
builder.add(addChild, 0, addChild.length, false);
|
||||
|
@ -464,8 +464,8 @@ public class BulkTests extends ElasticsearchIntegrationTest {
|
|||
byte[] addParent = new BytesArray("{\"index\" : { \"_index\" : \"test\", \"_type\" : \"parent\", \"_id\" : \"parent1\"}}\n" +
|
||||
"{\"field1\" : \"value1\"}\n").array();
|
||||
|
||||
byte[] addChild = new BytesArray("{\"update\" : { \"_id\" : \"child1\", \"_type\" : \"child\", \"_index\" : \"test\", \"routing\" : \"parent1\"} }\n" +
|
||||
"{ \"script\" : \"ctx._source.field2 = 'value2'\", \"upsert\" : {\"field1\" : \"value1\", \"_parent\" : \"parent1\"}}\n").array();
|
||||
byte[] addChild = new BytesArray("{\"update\" : { \"_id\" : \"child1\", \"_type\" : \"child\", \"_index\" : \"test\", \"parent\" : \"parent1\"} }\n" +
|
||||
"{ \"script\" : \"ctx._source.field2 = 'value2'\", \"upsert\" : {\"field1\" : \"value1\"}}\n").array();
|
||||
|
||||
builder.add(addParent, 0, addParent.length, false);
|
||||
builder.add(addChild, 0, addChild.length, false);
|
||||
|
|
|
@ -256,7 +256,7 @@ public class ChildrenTests extends ElasticsearchIntegrationTest {
|
|||
|
||||
String idToUpdate = Integer.toString(randomInt(3));
|
||||
UpdateResponse updateResponse = client().prepareUpdate(indexName, "child", idToUpdate)
|
||||
.setRouting("1")
|
||||
.setParent("1")
|
||||
.setDoc("count", 1)
|
||||
.get();
|
||||
assertThat(updateResponse.getVersion(), greaterThan(1l));
|
||||
|
|
Loading…
Reference in New Issue