Removed parent parameter from update request, because it is just sets the routing.
The routing option should be used instead. The parent a child document points to can't be updated. Closes #4538
This commit is contained in:
parent
687be70736
commit
20f7be378b
|
@ -200,8 +200,6 @@ 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.
|
||||
|
||||
`replication`:: The replication type for the delete/index operation
|
||||
|
|
|
@ -110,3 +110,8 @@ large, it is recommended to make it replicated to all nodes by setting
|
|||
`index.auto_expand_replicas: 0-all` in order to remove the network overhead as
|
||||
well.
|
||||
|
||||
=== Parent parameter on update request
|
||||
|
||||
The `parent` parameter has been removed from the update request. Before 2.x it just set the routing parameter. The
|
||||
`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.
|
|
@ -36,10 +36,6 @@
|
|||
"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
|
||||
parent: 5
|
||||
routing: 5
|
||||
body:
|
||||
doc: { foo: baz }
|
||||
upsert: { foo: bar }
|
||||
upsert: { foo: bar, _parent: 5 }
|
||||
|
||||
- do:
|
||||
get:
|
||||
|
@ -50,7 +50,7 @@ setup:
|
|||
index: test_1
|
||||
type: test
|
||||
id: 1
|
||||
parent: 5
|
||||
routing: 5
|
||||
fields: foo
|
||||
body:
|
||||
doc: { foo: baz }
|
||||
|
|
|
@ -21,11 +21,10 @@
|
|||
index: test_1
|
||||
type: test
|
||||
id: 1
|
||||
parent: 5
|
||||
routing: 4
|
||||
body:
|
||||
doc: { foo: baz }
|
||||
upsert: { foo: bar }
|
||||
upsert: { foo: bar, _parent: 5 }
|
||||
|
||||
- do:
|
||||
get:
|
||||
|
@ -45,7 +44,7 @@
|
|||
index: test_1
|
||||
type: test
|
||||
id: 1
|
||||
parent: 5
|
||||
routing: 5
|
||||
body:
|
||||
doc: { foo: baz }
|
||||
|
||||
|
@ -54,7 +53,6 @@
|
|||
index: test_1
|
||||
type: test
|
||||
id: 1
|
||||
parent: 5
|
||||
routing: 4
|
||||
fields: foo
|
||||
body:
|
||||
|
|
|
@ -353,14 +353,13 @@ 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).parent(parent).retryOnConflict(retryOnConflict)
|
||||
UpdateRequest updateRequest = new UpdateRequest(index, type, id).routing(routing).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);
|
||||
|
@ -369,7 +368,6 @@ 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);
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
package org.elasticsearch.action.update;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.action.DocumentRequest;
|
||||
import org.elasticsearch.action.WriteConsistencyLevel;
|
||||
|
@ -174,17 +173,6 @@ 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.
|
||||
|
|
|
@ -70,11 +70,6 @@ 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.
|
||||
|
|
|
@ -58,7 +58,6 @@ 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 replicationType = request.param("replication");
|
||||
|
|
|
@ -425,8 +425,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\", \"parent\" : \"parent1\"}}\n" +
|
||||
"{\"doc\" : { \"field1\" : \"value1\"}, \"doc_as_upsert\" : \"true\"}\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();
|
||||
|
||||
builder.add(addParent, 0, addParent.length, false);
|
||||
builder.add(addChild, 0, addChild.length, false);
|
||||
|
@ -462,8 +462,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\", \"parent\" : \"parent1\"} }\n" +
|
||||
"{ \"script\" : \"ctx._source.field2 = 'value2'\", \"upsert\" : {\"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();
|
||||
|
||||
builder.add(addParent, 0, addParent.length, false);
|
||||
builder.add(addChild, 0, addChild.length, false);
|
||||
|
|
|
@ -248,7 +248,7 @@ public class ChildrenTests extends ElasticsearchIntegrationTest {
|
|||
|
||||
String idToUpdate = Integer.toString(randomInt(3));
|
||||
UpdateResponse updateResponse = client().prepareUpdate(indexName, "child", idToUpdate)
|
||||
.setParent("1")
|
||||
.setRouting("1")
|
||||
.setDoc("count", 1)
|
||||
.get();
|
||||
assertThat(updateResponse.getVersion(), greaterThan(1l));
|
||||
|
|
Loading…
Reference in New Issue