问题描述
学习 Elasticsearch 时遇到下面的指令
curl -XPOST http://localhost:9200/website/blog/1/_update?pretty -d '
{
"script":"ctx.op = ctx._source.views == count ? 'delete' : 'none'",
"params":{
"count":1
}
}'
输入之后出现错误
{
"error" : {
"root_cause" : [ {
"type" : "remote_transport_exception",
"reason" : "[Noh-Varr][127.0.0.1:9300][indices:data/write/update[s]]"
} ],
"type" : "illegal_argument_exception",
"reason" : "failed to execute script",
"caused_by" : {
"type" : "groovy_script_execution_exception",
"reason" : "failed to run inline script [ctx.op = ctx._source.views == count ? delete : none] using lang [groovy]",
"caused_by" : {
"type" : "missing_property_exception",
"reason" : "No such property: delete for class: c30a274307ef10b240f1f85b3ca62f105ece21af"
}
}
},
"status" : 400
}
产生原因
此问题由单引号引起
解决办法
将指令改为以下形式
curl -XPOST http://localhost:9200/website/blog/1/_update?pretty -d '
{
"script":"ctx.op = ctx._source.views == count ? '"'"'delete'"'"' : '"'"'none'"'",
"params":{
"count":1
}
}'
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于