use of core.framework.search.UpdateRequest in project core-ng-project by neowu.
the class ElasticSearchTypeImpl method update.
@Override
public void update(UpdateRequest<T> request) {
var watch = new StopWatch();
if (request.script == null)
throw new Error("request.script must not be null");
String index = request.index == null ? this.index : request.index;
try {
Map<String, JsonData> params = request.params == null ? Map.of() : request.params.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, value -> JsonData.of(value.getValue())));
elasticSearch.client.update(builder -> builder.index(index).id(request.id).script(s -> s.inline(i -> i.source(request.script).params(params))), documentClass);
} catch (IOException e) {
throw new UncheckedIOException(e);
} catch (ElasticsearchException e) {
throw elasticSearch.searchException(e);
} finally {
long elapsed = watch.elapsed();
ActionLogContext.track("elasticsearch", elapsed, 0, 1);
logger.debug("update, index={}, id={}, script={}, elapsed={}", index, request.id, request.script, elapsed);
checkSlowOperation(elapsed);
}
}
Aggregations