private UpdateRequest prepareUpdate(UpdateQuery query) { String indexName = hasText(query.getIndexName()) ? query.getIndexName() : getPersistentEntityFor(query.getClazz()).getIndexName(); String type = hasText(query.getType()) ? query.getType() : getPersistentEntityFor(query.getClazz()).getIndexType(); Assert.notNull(indexName, "No index defined for Query"); Assert.notNull(type, "No type define for Query"); Assert.notNull(query.getId(), "No Id define for Query"); Assert.notNull(query.getUpdateRequest(), "No IndexRequest define for Query"); UpdateRequest updateRequest = new UpdateRequest(indexName, type, query.getId()); updateRequest.routing(query.getUpdateRequest().routing()); if (query.getUpdateRequest().script() == null) { // doc if (query.DoUpsert()) { updateRequest.docAsUpsert(true).doc(query.getUpdateRequest().doc()); } else { updateRequest.doc(query.getUpdateRequest().doc()); } } else { // or script updateRequest.script(query.getUpdateRequest().script()); } return updateRequest; }
/** * Controls the shard routing of the request. Using this value to hash the shard * and not the id. */ public UpdateRequestBuilder setRouting(String routing) { request.routing(routing); return this; }
parameters.withRouting(updateRequest.routing()); parameters.withTimeout(updateRequest.timeout()); parameters.withRefreshPolicy(updateRequest.getRefreshPolicy());
public static void resolveAndValidateRouting(MetaData metaData, String concreteIndex, UpdateRequest request) { request.routing((metaData.resolveWriteIndexRouting(request.parent(), request.routing(), request.index()))); // Fail fast on the node that received the request, rather than failing when translating on the index or delete request. if (request.routing() == null && metaData.routingRequired(concreteIndex, request.type())) { throw new RoutingMissingException(concreteIndex, request.type(), request.id()); } }
/** * Controls the shard routing of the request. Using this value to hash the shard * and not the id. */ public UpdateRequestBuilder setRouting(String routing) { request.routing(routing); return this; }
/** * Controls the shard routing of the request. Using this value to hash the shard * and not the id. */ public UpdateRequestBuilder setRouting(String routing) { request.routing(routing); return this; }
/** * Controls the shard routing of the request. Using this value to hash the shard * and not the id. */ public UpdateRequestBuilder setRouting(String routing) { request.routing(routing); return this; }
/** * Controls the shard routing of the request. Using this value to hash the shard * and not the id. */ public UpdateRequestBuilder setRouting(String routing) { request.routing(routing); return this; }
public UpdateRequestBuilder<JsonInput, JsonOutput> routing(String routing) { request.routing(routing); return this; }
@Override protected ShardIterator shards(ClusterState clusterState, UpdateRequest request) { if (request.getShardId() != null) { return clusterState.routingTable().index(request.concreteIndex()).shard(request.getShardId().getId()).primaryShardIt(); } ShardIterator shardIterator = clusterService.operationRouting() .indexShards(clusterState, request.concreteIndex(), request.id(), request.routing()); ShardRouting shard; while ((shard = shardIterator.nextOrNull()) != null) { if (shard.primary()) { return new PlainShardIterator(shardIterator.shardId(), Collections.singletonList(shard)); } } return new PlainShardIterator(shardIterator.shardId(), Collections.emptyList()); }
.source(sliceTrimmingCarriageReturn(data, from, nextMarker, xContentType), xContentType), payload); } else if ("update".equals(action)) { UpdateRequest updateRequest = new UpdateRequest(index, type, id).routing(routing).parent(parent) .retryOnConflict(retryOnConflict).version(version).versionType(versionType) .routing(routing) .parent(parent);
public static void resolveAndValidateRouting(MetaData metaData, String concreteIndex, UpdateRequest request) { request.routing((metaData.resolveIndexRouting(request.routing(), request.index()))); // Fail fast on the node that received the request, rather than failing when translating on the index or delete request. if (request.routing() == null && metaData.routingRequired(concreteIndex, request.type())) { throw new RoutingMissingException(concreteIndex, request.type(), request.id()); } }
public static void resolveAndValidateRouting(MetaData metaData, String concreteIndex, UpdateRequest request) { request.routing((metaData.resolveIndexRouting(request.parent(), request.routing(), request.index()))); // Fail fast on the node that received the request, rather than failing when translating on the index or delete request. if (request.routing() == null && metaData.routingRequired(concreteIndex, request.type())) { throw new RoutingMissingException(concreteIndex, request.type(), request.id()); } }
public static void resolveAndValidateRouting(MetaData metaData, String concreteIndex, UpdateRequest request) { request.routing((metaData.resolveWriteIndexRouting(request.parent(), request.routing(), request.index()))); // Fail fast on the node that received the request, rather than failing when translating on the index or delete request. if (request.routing() == null && metaData.routingRequired(concreteIndex, request.type())) { throw new RoutingMissingException(concreteIndex, request.type(), request.id()); } }
public static void resolveAndValidateRouting(MetaData metaData, String concreteIndex, UpdateRequest request) { request.routing((metaData.resolveWriteIndexRouting(request.parent(), request.routing(), request.index()))); // Fail fast on the node that received the request, rather than failing when translating on the index or delete request. if (request.routing() == null && metaData.routingRequired(concreteIndex, request.type())) { throw new RoutingMissingException(concreteIndex, request.type(), request.id()); } }
@Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { UpdateRequest updateRequest = new UpdateRequest(request.param("index"), request.param("type"), request.param("id")); updateRequest.routing(request.param("routing")); updateRequest.parent(request.param("parent")); updateRequest.timeout(request.paramAsTime("timeout", updateRequest.timeout())); client.update(updateRequest, new RestStatusToXContentListener<>(channel, r -> r.getLocation(updateRequest.routing())));
.type(request.type()).id(request.id()).setRefreshPolicy(request.getRefreshPolicy()).routing(request.routing()) .parent(request.parent()).timeout(request.timeout()).waitForActiveShards(request.waitForActiveShards())
public void updateElement(Element element, String index, String routing, boolean upsert) throws ExecutionException, InterruptedException { UpdateRequest updateRequest = new UpdateRequest(index, element.label(), element.id().toString()) .doc(propertiesMap(element)).routing(routing); if(upsert) updateRequest.detectNoop(true).docAsUpsert(true); if(bulkRequest != null) bulkRequest.add(updateRequest); else client.update(updateRequest).actionGet(); revision++; }
@Override protected ShardIterator shards(ClusterState clusterState, UpdateRequest request) { if (request.getShardId() != null) { return clusterState.routingTable().index(request.concreteIndex()).shard(request.getShardId().getId()).primaryShardIt(); } ShardIterator shardIterator = clusterService.operationRouting() .indexShards(clusterState, request.concreteIndex(), request.id(), request.routing()); ShardRouting shard; while ((shard = shardIterator.nextOrNull()) != null) { if (shard.primary()) { return new PlainShardIterator(shardIterator.shardId(), Collections.singletonList(shard)); } } return new PlainShardIterator(shardIterator.shardId(), Collections.emptyList()); }
@Override protected ShardIterator shards(ClusterState clusterState, UpdateRequest request) { if (request.getShardId() != null) { return clusterState.routingTable().index(request.concreteIndex()).shard(request.getShardId().getId()).primaryShardIt(); } ShardIterator shardIterator = clusterService.operationRouting() .indexShards(clusterState, request.concreteIndex(), request.id(), request.routing()); ShardRouting shard; while ((shard = shardIterator.nextOrNull()) != null) { if (shard.primary()) { return new PlainShardIterator(shardIterator.shardId(), Collections.singletonList(shard)); } } return new PlainShardIterator(shardIterator.shardId(), Collections.<ShardRouting>emptyList()); }