提问要多花一点心思哦

使用java使用script更新出现DocumentMissingException

Elasticsearch | 作者 ColouredGlaze | 发布于2018年01月27日 | 阅读数:5491

UpdateRequest updateRequest = new UpdateRequest(UdConstant.ES_INDEX, this.ES_TYPE, esId)
.script(new Script("ctx._source.downloadNum += 1"));
try {
UpdateResponse updateResponse = client.update(updateRequest).get();
System.err.println("ES更新下载次数时返回的status:" + updateResponse.status().getStatus());
} catch (InterruptedException e) {
logger.error("ES更新下载次数时出现异常: InterruptedException");
e.printStackTrace();
} catch (ExecutionException e) {
logger.error("ES更新下载次数时出现异常: ExecutionException");
e.printStackTrace();
}
 
官网代码:
UpdateRequest updateRequest = new UpdateRequest("ttl", "doc", "1")
.script(new Script("ctx._source.gender = \"male\""));
client.update(updateRequest).get();

执行之后出现ExecutionException,
异常信息:
Caused by: RemoteTransportException[[master][127.0.0.1:9300][indices:data/write/update]]; nested: RemoteTransportException[[master][127.0.0.1:9300][indices:data/write/update[s]]]; nested: DocumentMissingException[[resource][undefined]: document missing];
Caused by: RemoteTransportException[[master][127.0.0.1:9300][indices:data/write/update[s]]]; nested: DocumentMissingException[[resource][undefined]: document missing];
Caused by: [unstructured_data/riGHta_STCiWrf_o5ZxgqQ][[unstructured_data][1]] DocumentMissingException[[resource][undefined]: document missing]
 
求帮忙  感激不尽!
已邀请:

ColouredGlaze

赞同来自:

不好意思,好像是esId不对   。。。

要回复问题请先登录注册