简体   繁体   English

在Elasticsearch 1.5中是否可以通过查询更新所有文档?

[英]Is there a way to update all documents by query in Elasticsearch 1.5?

We made some mistake to put one of the field with accent. 为了弄清重点,我们犯了一些错误。 So, the field contains é and we would like to update that to e . 因此,该字段包含é ,我们希望将其更新为e

We're using Elasticsearch 1.5. 我们正在使用Elasticsearch 1.5。 Is there a query we can run to update all the documents in one go or do I need to query all the documents and update them all using Elasticsearch lib? 是否可以运行一次查询以更新所有文档,还是需要查询所有文档并使用Elasticsearch lib更新所有文档?

We're using node.js 我们正在使用node.js

If you're running ES 1.5, you can install the update-by-query plugin like this: 如果您正在运行ES 1.5,则可以按以下方式安装按查询更新插件:

bin/plugin -install com.yakaz.elasticsearch.plugins/elasticsearch-action-updatebyquery/2.5.1

When done, you can restart your ES server, and run the following query: 完成后,您可以重新启动ES服务器,并运行以下查询:

curl -XPOST 'localhost:9200/your_index/_update_by_query' -d '{
    "query" : {
        "match_all" : {}
    },
    "script" : "ctx._source.field = 'foo'"
}'

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

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