elasticsearch - ES更新给出了错误的请求

标签 elasticsearch

我正在尝试更新以下文档:

$ curl http://192.168.0.108:9200/customer/customer/AVGbTCQ2XioLLLZULBAD?pretty
{
  "_index" : "customer",
  "_type" : "customer",
  "_id" : "AVGbTCQ2XioLLLZULBAD",
  "_version" : 15,
  "found" : true,
  "_source":{"age":0,"n":"Abhishek Gupta","id":"AVGbTCQ2XioLLLZULBAD"}
}

根据update API我的更新请求是:
$ curl -XPOST http://192.168.0.108:9200/customer/customer/AVGbTCQ2XioLLLZULBAD/_update -d '{
>   "script": {
>     "inline": "ctx._source.n = name",
>     "params": {
>       "name": "Elas"
>     }
>   }
> }'
{"error":"ActionRequestValidationException[Validation Failed: 1: script or doc is missing;]","status":400}

为什么我收到不好的要求?

ES版本详细信息:
$ curl http://192.168.0.108:9200/
{
  "status" : 200,
  "name" : "Vance Astro",
  "cluster_name" : "dexter-elasticsearch",
  "version" : {
    "number" : "1.7.1",
    "build_hash" : "b88f43fc40b0bcd7f173a1f9ee2e97816de80b19",
    "build_timestamp" : "2015-07-29T09:54:16Z",
    "build_snapshot" : false,
    "lucene_version" : "4.10.4"
  },
  "tagline" : "You Know, for Search"
}

最佳答案

Scripted updated in ES 1.7.1与ES 2.x中的略有不同,即ES 2.x中没有 inline parameter,而是这样编写:

curl -XPOST http://192.168.0.108:9200/customer/customer/AVGbTCQ2XioLLLZULBAD/_update -d '{
    "script": "ctx._source.n = name",
    "params": {
      "name": "Elas"
    }
}' 

关于elasticsearch - ES更新给出了错误的请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34350566/

相关文章:

elasticsearch - 如何在 Elasticsearch 中实现同义词?

elasticsearch - 如何在ElasticSearch中按_version排序数据

更新数据路径时 Elasticsearch 崩溃

elasticsearch - 如何使用 ElasticSearch 在字符串字段中搜索精确短语?

elasticsearch - 在Elasticsearch中按内部字段搜索

linux - Elastic filebeat 6.5.1错误: failed to read process cgroups

docker - 在 kubernetes statefulset 中的 elasticsearch 数据目录上 chown 时权限被拒绝

ruby - 使用 ruby gem ,而仅使用sinatra和 ruby (而不是铁轨),如何连接到盆景elasticsearch实例?

elasticsearch - Elasticsearch API:SearchQuery和SearchResponse之间的区别?

elasticsearch - Filebeat的KV处理器