初学Elasticsearch,在按照《Elasticsearch服务器开发(第2版)》进行学习的过程中,在P17页中1.4.5 更新文档小节,使用脚本对文档进行局部更新的时候遇到了如下报错:
~ curl -XPOST http://127.0.0.1:9200/blog/article/1/_update -d '{"script": "ctx._source.content=\"new content\""}'
{
"error":{
"root_cause":[{
"type":"remote_transport_exception",
"reason":"[Lady Mandarin][127.0.0.1:9300][indices:data/write/update]"
}
],
"type":"illegal_argument_exception",
"reason":"failed to execute script",
"caused_by":{
"type":"script_exception",
"reason":"scripts of type [inline], operation [update] and lang [groovy] are disabled"}},
"status":400
}%我根据提示中的原因"scripts of type [inline], operation [update] and lang [groovy] are disabled"进行了查询,查到了官网文档关于对脚本更新的介绍(介绍链接)。
通过粗略查看文档,我发现要解决这个问题,需要在Elasticsearch的配置文件elasticsearch.yml中添加如下配置: