@Override public void updateWorkflow(String workflowInstanceId, String[] keys, Object[] values) { if (keys.length != values.length) { throw new ApplicationException(Code.INVALID_INPUT, "Number of keys and values do not match"); } UpdateRequest request = new UpdateRequest(indexName, WORKFLOW_DOC_TYPE, workflowInstanceId); Map<String, Object> source = IntStream.range(0, keys.length) .boxed() .collect(Collectors.toMap(i -> keys[i], i -> values[i])); request.doc(source); logger.debug("Updating workflow {} with {}", workflowInstanceId, source); new RetryUtil<>().retryOnException( () -> elasticSearchClient.update(request), null, null, RETRY_COUNT, "Updating index for doc_type workflow", "updateWorkflow" ); }
private void updateWithRetry(UpdateRequest request, String operationDescription) { try { new RetryUtil<UpdateResponse>().retryOnException( () -> elasticSearchClient.update(request).actionGet(), null, null, RETRY_COUNT, operationDescription, "updateWithRetry" ); } catch (Exception e) { Monitors.error(className, "index"); logger.error("Failed to index {} for request type: {}", request.index(), request.type(), e); } }
@Override protected ActionFuture<UpdateResponse> doExecute(UpdateRequest request) { return client.update(request); }
for (;;) { for (Client c : clients) { c.update(); } Thread.sleep(1000); }
@BodyParser.Of(play.mvc.BodyParser.Json.class) public static Result editClientJSON() { Logger.debug("Reached editClientJSON"); Form<Client> clientForm = Form.form(Client.class).bindFromRequest(); if(clientForm.hasErrors()) {//check out for form errors for (String errorKey : clientForm.errors().keySet()) { for (ValidationError error : clientForm.errors().get(errorKey)) { Logger.error(error.key() + " = " + error.message()); } } return badRequest(); } //There is no error on the form so it is now safe to get the Client Client client = clientForm.get(); client.update(); Logger.debug("Client updated: " + client.name); response().setHeader(LOCATION, routes.ClientCtrl.getClientJSON(client.id).url()); return ok(); }
protected UpdateResponse update(String id, byte[] doc) { UpdateRequest updateRequest = new UpdateRequest(getIndexName(), getDocTypeName(), id).doc(doc); return esClient.update(updateRequest).actionGet(); }
protected UpdateResponse update(String id, byte[] doc, long version) { UpdateRequest updateRequest = new UpdateRequest(getIndexName(), getDocTypeName(), id).doc(doc).version(version); return esClient.update(updateRequest).actionGet(); }
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++; }
client.update(updateRequest).get(); }catch(Exception e) { if( ExceptionUtils.getRootCause(e) instanceof DocumentMissingException) {
.upsert(indexRequest); UpdateResponse response = client.update(upReq).get();
protected UpdateResponse updateOrInsert(String id, byte[] updateDoc, byte[] insertDoc) throws Exception { IndexRequest indexRequest = new IndexRequest(getIndexName(), getDocTypeName(), id).source(insertDoc); UpdateRequest updateRequest = new UpdateRequest(getIndexName(), getDocTypeName(), id).doc(updateDoc).upsert(indexRequest); return esClient.update(updateRequest).actionGet(); }
@Override public UpdateResponse upsert(UpdateRequest upsertRequest) throws ClientException { checkClient(); Map<String, Object> storableMap = modelContext.marshal(upsertRequest.getStorable()); logger.debug("Upsert - converted object: '{}'", storableMap); org.elasticsearch.action.index.IndexRequest idxRequest = new org.elasticsearch.action.index.IndexRequest(upsertRequest.getTypeDescriptor().getIndex(), upsertRequest.getTypeDescriptor().getType(), upsertRequest.getId()).source(storableMap); org.elasticsearch.action.update.UpdateRequest updateRequest = new org.elasticsearch.action.update.UpdateRequest(upsertRequest.getTypeDescriptor().getIndex(), upsertRequest.getTypeDescriptor().getType(), upsertRequest.getId()).doc(storableMap); org.elasticsearch.action.update.UpdateResponse response = esClientProvider.getClient().update(updateRequest.upsert(idxRequest)).actionGet(getQueryTimeout()); return new UpdateResponse(response.getId(), upsertRequest.getTypeDescriptor()); }
@Override public UpdateResponse upsert(UpdateRequest upsertRequest) throws ClientException { checkClient(); Map<String, Object> storableMap = modelContext.marshal(upsertRequest.getStorable()); logger.debug("Upsert - converted object: '{}'", storableMap); org.elasticsearch.action.index.IndexRequest idxRequest = new org.elasticsearch.action.index.IndexRequest(upsertRequest.getTypeDescriptor().getIndex(), upsertRequest.getTypeDescriptor().getType(), upsertRequest.getId()).source(storableMap); org.elasticsearch.action.update.UpdateRequest updateRequest = new org.elasticsearch.action.update.UpdateRequest(upsertRequest.getTypeDescriptor().getIndex(), upsertRequest.getTypeDescriptor().getType(), upsertRequest.getId()).doc(storableMap); org.elasticsearch.action.update.UpdateResponse response = esClientProvider.getClient().update(updateRequest.upsert(idxRequest)).actionGet(getQueryTimeout()); return new UpdateResponse(response.getId(), upsertRequest.getTypeDescriptor()); }
client.update(updateRequest, new RestBuilderListener<UpdateResponse>(channel) { @Override public RestResponse buildResponse(UpdateResponse response, XContentBuilder builder) throws Exception {