在elasticsearch中更新所有记录中的字段 [英] Updating a field in all records in elasticsearch

查看:48
本文介绍了在elasticsearch中更新所有记录中的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 ElasticSearch 的新手,所以这可能是一件非常微不足道的事情,但我还没有想出比获取所有内容、使用脚本处理和逐个更新寄存器更好的方法.

I'm new to ElasticSearch, so this is probably something quite trivial, but I haven't figured out anything better that fetching everything, processing with a script and updating the registers one by one.

我想做一个简单的 SQL 更新:

I want to make something like a simple SQL update:

UPDATE RECORD SET SOMEFIELD = SOMEXPRESSION

我的意图是用一些更有意义的数据替换实际的虚假数据(因此表达式基本上是从有效值池中随机选择).

My intent is to replace the actual bogus data with some data that makes more sense (so the expression is basically randomly choosing from a pool of valid values).

推荐答案

有几个open 问题 关于通过查询更新文档成为可能.

There are a couple of open issues about making possible to update documents by query.

技术挑战在于 lucene(Elasticsearch 在后台使用的文本搜索引擎库)段是只读的.您永远不能修改现有文档.您需要做的是删除文档的旧版本(顺便说一句,它只会被标记为已删除,直到发生段合并)并索引新版本.这就是现有的 update api 所做的.因此,查询更新可能需要很长时间并导致问题,这就是它尚未发布的原因.对于这种情况,允许中断正在运行的查询的机制也很不错.

The technical challenge is that lucene (the text search engine library that elasticsearch uses under the hood) segments are read only. You can never modify an existing document. What you need to do is delete the old version of the document (which by the way will only be marked as deleted till a segment merge happens) and index the new one. That's what the existing update api does. Therefore, an update by query might take a long time and lead to issues, that's why it's not released yet. A mechanism that allows to interrupt running queries would be a nice to have too for this case.

但是有 通过查询插件更新 正是公开了该功能.使用前请注意潜在风险.

But there's the update by query plugin that exposes exactly that feature. Just beware of the potential risks before using it.

这篇关于在elasticsearch中更新所有记录中的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆