我正在使用Jest Java HTTP Rest客户端为Elasticsearch进行crud操作。
我有更新弹性搜索文档的脚本更新。下面是我的脚本示例
String script = "{\n" +
" \"script\" : \"ctx._source.indicator = tag\",\n" +
" \"params\" : {\n" +
" \"tag\" : \"P\"\n" +
" }\n" +
"}";
并使用jest update api,我可以更新文档。见下文。
jestClient.execute(new Update.Builder(script).index(indexName).type("I").id(documentId).build());
我还在弹性搜索yml文件中添加了script.inline = true,没有上面提到的脚本更新,我们就无法工作。
此更新操作与Elastic Search 2.x版本完美配合,但最近我们将Elastic Search从2.x升级到5.x,现在我的Elastic Search文档没有得到更新。
最近我在Elastic Search助手类的帮助下生成了上面提到的脚本来创建JSON。下面是我的JSON,它将转到Elastic Search服务器
{
"script" : {
"source": "ctx._source.requeue_parent_child_indicator =
params.requeueIndicator",
"lang": "painless",
"params" : {
"requeueIndicator" : "P"
}
}
}
此脚本在通过最新的kibana开发工具执行时有效。我的弹性搜索文档正在更新,但它没有通过JEST API(更新构建器)进行更新