本文整理了Java中org.elasticsearch.client.Client.update()
方法的一些代码示例,展示了Client.update()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Client.update()
方法的具体详情如下:
包路径:org.elasticsearch.client.Client
类名称:Client
方法名:update
[英]Updates a document based on a script.
[中]基于脚本更新文档。
代码示例来源:origin: Netflix/conductor
@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"
);
}
代码示例来源:origin: Netflix/conductor
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);
}
}
代码示例来源:origin: javanna/elasticshell
@Override
protected ActionFuture<UpdateResponse> doExecute(UpdateRequest request) {
return client.update(request);
}
代码示例来源:origin: stackoverflow.com
for (;;) {
for (Client c : clients) {
c.update();
}
Thread.sleep(1000);
}
代码示例来源:origin: stackoverflow.com
@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();
}
代码示例来源:origin: pinterest/soundwave
protected UpdateResponse update(String id, byte[] doc) {
UpdateRequest
updateRequest =
new UpdateRequest(getIndexName(), getDocTypeName(), id).doc(doc);
return esClient.update(updateRequest).actionGet();
}
代码示例来源:origin: pinterest/soundwave
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();
}
代码示例来源:origin: rmagen/elastic-gremlin
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++;
}
代码示例来源:origin: apache/jena
client.update(updateRequest).get();
}catch(Exception e) {
if( ExceptionUtils.getRootCause(e) instanceof DocumentMissingException) {
代码示例来源:origin: apache/jena
.upsert(indexRequest);
UpdateResponse response = client.update(upReq).get();
代码示例来源:origin: pinterest/soundwave
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();
}
代码示例来源:origin: eclipse/kapua
@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());
}
代码示例来源:origin: org.eclipse.kapua/kapua-datastore-client-transport
@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());
}
代码示例来源:origin: harbby/presto-connectors
client.update(updateRequest, new RestBuilderListener<UpdateResponse>(channel) {
@Override
public RestResponse buildResponse(UpdateResponse response, XContentBuilder builder) throws Exception {
内容来源于网络,如有侵权,请联系作者删除!