本文整理了Java中org.elasticsearch.client.RestHighLevelClient.update
方法的一些代码示例,展示了RestHighLevelClient.update
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RestHighLevelClient.update
方法的具体详情如下:
包路径:org.elasticsearch.client.RestHighLevelClient
类名称:RestHighLevelClient
方法名:update
[英]Updates a document using the Update API. See Update API on elastic.co
[中]使用更新API更新文档。见Update API on elastic.co
代码示例来源:origin: Netflix/conductor
@Override
public void updateWorkflow(String workflowInstanceId, String[] keys, Object[] values) {
if (keys.length != values.length) {
throw new ApplicationException(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<UpdateResponse>().retryOnException(() -> {
try {
return elasticSearchClient.update(request);
} catch (IOException e) {
throw new RuntimeException(e);
}
}, null, null, RETRY_COUNT, "Updating index for doc_type workflow", "updateWorkflow");
}
代码示例来源:origin: spring-projects/spring-data-elasticsearch
@Override
public UpdateResponse update(UpdateQuery query) {
UpdateRequest request = prepareUpdate(query);
try {
return client.update(request);
} catch (IOException e) {
throw new ElasticsearchException("Error while update for request: " + request.toString(), e);
}
}
代码示例来源:origin: tomoya92/pybbs
public void updateDocument(String type, String id, Map<String, Object> source) {
try {
if (this.instance() == null) return;
UpdateRequest request = new UpdateRequest(name, type, id);
request.doc(source);
client.update(request, RequestOptions.DEFAULT);
} catch (IOException e) {
log.error(e.getMessage());
}
}
代码示例来源:origin: dqeasycloud/easy-cloud
public UpdateResponse update(String indexName, String type, String id) throws IOException {
try {
Map<String, Object> jsonMap = new HashMap<>();
jsonMap.put("updated", new Date());
jsonMap.put("reason", "daily update");
UpdateRequest request = new UpdateRequest("posts", "doc", "1")
.doc(jsonMap);
UpdateResponse updateResponse = client.update(request);
return updateResponse;
} catch (ElasticsearchException exception) {
if (exception.status() == RestStatus.NOT_FOUND) {
}
}
return null;
}
代码示例来源:origin: com.wuyushuo/vplus-data
@Override
public UpdateResponse updateIndex(String index, String type, String id, Object source) throws Exception{
UpdateRequest request = new UpdateRequest(index, type, id).doc(JSON.toJSONString(source), XContentType.JSON);
log.debug(request.toString());
return client().update(request);
}
代码示例来源:origin: com.wuyushuo/vplus-data
@Override
public UpdateResponse upsertIndex(String index, String type, String id, Object source) throws Exception {
UpdateRequest request = new UpdateRequest(index, type, id).docAsUpsert(true).doc(JSON.toJSONString(source), XContentType.JSON);
log.debug(request.toString());
return client().update(request);
}
代码示例来源:origin: eea/eea.elasticsearch.river.rdf
private void setClusterStatus(String status) {
String statusIndex = indexName + "_status";
boolean indexing = false;
GetRequest getRequest = new GetRequest(statusIndex, "last_update" , riverName);
try {
GetResponse getResponse = client.get(getRequest);
if(getResponse.getSource().get("status") == "indexing"){
indexing = true;
}
} catch (IOException e) {
//e.printStackTrace();
}
if(!indexing){
Map<String, Object> jsonMap = new HashMap<>();
jsonMap.put("status", status);
UpdateRequest request = new UpdateRequest( statusIndex, "last_update", riverName)
.doc(jsonMap);
try {
UpdateResponse updateResponse = client.update(request);
logger.info("Updating index {} status to: indexing", riverName);
} catch (IOException e) {
logger.error("{}", e);
}
} else {
}
}
代码示例来源:origin: lukas-krecan/ShedLock
@Override
public void unlock() {
// Set lockUtil to now or lockAtLeastUntil whichever is later
try {
UpdateRequest ur = new UpdateRequest()
.index(index)
.type(type)
.id(lockConfiguration.getName())
.script(new Script(ScriptType.INLINE,
"painless",
"ctx._source.lockUntil = params.unlockTime",
Collections.singletonMap("unlockTime", lockConfiguration.getUnlockTime().toEpochMilli())));
highLevelClient.update(ur, RequestOptions.DEFAULT);
} catch (IOException | ElasticsearchException e) {
throw new LockException("Unexpected exception occurred", e);
}
}
}
代码示例来源:origin: hakdogan/ElasticSearch
/**
*
* @param document
* @return
*/
public String updateDocument(Document document){
try {
UpdateRequest request = new UpdateRequest(props.getIndex().getName(),
props.getIndex().getType(), document.getId())
.doc(gson.toJson(document), XContentType.JSON);
UpdateResponse response = client.update(request);
return response.getId();
} catch (Exception ex){
log.error("The exception was thrown in updateDocument method. {} ", ex);
}
return null;
}
代码示例来源:origin: org.apache.camel/camel-elasticsearch-rest
} else if (operation == ElasticsearchOperation.Update) {
UpdateRequest updateRequest = message.getBody(UpdateRequest.class);
message.setBody(restHighLevelClient.update(updateRequest, RequestOptions.DEFAULT).getId());
} else if (operation == ElasticsearchOperation.GetById) {
GetRequest getRequest = message.getBody(GetRequest.class);
代码示例来源:origin: lukas-krecan/ShedLock
UpdateResponse res = highLevelClient.update(ur, RequestOptions.DEFAULT);
if (res.getResult() != DocWriteResponse.Result.NOOP) {
return Optional.of(new ElasticsearchSimpleLock(lockConfiguration));
内容来源于网络,如有侵权,请联系作者删除!