更新弹性搜索中所有记录中的一个字段 [英] Updating a field in all records in elasticsearch

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

问题描述

我是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).

推荐答案

有几个打开 问题可以更新文档通过查询。

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

技术挑战是,lucene(弹性搜索引擎使用的文本搜索引擎库)段是只读的。您永远不能修改现有文档。您需要做的是删除旧版本的文档(其方式只会被标记为已删除,直到段合并发生),并对新的文档进行索引。这就是现有的更新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.

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

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