简体   繁体   English

elasticsearch 更新时返回文档

[英]elasticsearch return document on update

I need to get the updated document after update operation.更新操作后我需要获取更新的文档。

Using elasticsearch version 7.0.0 .使用 elasticsearch 版本7.0.0

I tried:我试过了:

curl -XPOST 'localhost:9200/dmf_product_match/_doc/YKsu3m0BxrmuyWilMQ-I/_update?fields=_source' -d '{
    "doc" : {
        "name" : "new_name"
    }
}'

But get this error.但是得到这个错误。

{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"request [/dmf_product_match/_doc/YKsu3m0BxrmuyWilMQ-I/_update] contains unrecognized parameter: [fields]"}],"type":"illegal_argument_exception","reason":"request [/dmf_product_match/_doc/YKsu3m0BxrmuyWilMQ-I/_update] contains unrecognized parameter: [fields]"},"status":400}

Try尝试

curl -XPOST 'localhost:9200/dmf_product_match/_update/YKsu3m0BxrmuyWilMQ-I?_source' -d '{
    "doc" : {
        "name" : "new_name"
    }
}'

You could also use "doc_as_upsert": true .您也可以使用"doc_as_upsert": true Reference: this参考: 这个

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM