use of org.springframework.data.elasticsearch.core.query.UpdateResponse in project spring-data-elasticsearch by spring-projects.
the class ReactiveElasticsearchTemplate method update.
@Override
public Mono<UpdateResponse> update(UpdateQuery updateQuery, IndexCoordinates index) {
Assert.notNull(updateQuery, "UpdateQuery must not be null");
Assert.notNull(index, "Index must not be null");
return Mono.defer(() -> {
UpdateRequest request = requestFactory.updateRequest(updateQuery, index);
if (updateQuery.getRefreshPolicy() == null && refreshPolicy != null) {
request.setRefreshPolicy(RequestFactory.toElasticsearchRefreshPolicy(refreshPolicy));
}
if (updateQuery.getRouting() == null && routingResolver.getRouting() != null) {
request.routing(routingResolver.getRouting());
}
return Mono.from(execute(client -> client.update(request))).map(response -> new UpdateResponse(UpdateResponse.Result.valueOf(response.getResult().name())));
});
}
use of org.springframework.data.elasticsearch.core.query.UpdateResponse in project spring-data-elasticsearch by spring-projects.
the class ElasticsearchRestTemplate method update.
@Override
public UpdateResponse update(UpdateQuery query, IndexCoordinates index) {
UpdateRequest request = requestFactory.updateRequest(query, index);
if (query.getRefreshPolicy() == null && getRefreshPolicy() != null) {
request.setRefreshPolicy(RequestFactory.toElasticsearchRefreshPolicy(getRefreshPolicy()));
}
if (query.getRouting() == null && routingResolver.getRouting() != null) {
request.routing(routingResolver.getRouting());
}
UpdateResponse.Result result = UpdateResponse.Result.valueOf(execute(client -> client.update(request, RequestOptions.DEFAULT)).getResult().name());
return new UpdateResponse(result);
}
use of org.springframework.data.elasticsearch.core.query.UpdateResponse in project IT-Demo by yanghaiji.
the class EsTempWeb method update.
/**
* <p>
* 更新
* </p>
*
* @param
* @return void
* @version 1.0.0
* @author hai ji
* @since 2022/2/9
*/
@PostMapping
public void update() {
Document document = Document.create();
document.put("title", 1214666);
document.put("price", 66.6);
UpdateQuery updateQuery = UpdateQuery.builder("164439571754").withDocument(document).build();
// 单条更新
UpdateResponse response = elasticsearchTemplate.update(updateQuery, IndexCoordinates.of("sys_user"));
System.out.println(response.getResult().name());
// 批量更新
List<UpdateQuery> list = new LinkedList<>();
list.add(updateQuery);
elasticsearchTemplate.bulkUpdate(list, IndexCoordinates.of("sys_user"));
}
Aggregations