从弹性搜索文档中删除一个字段 [英] Remove a field from a Elasticsearch document

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

问题描述

我需要删除索引到Elasticsearch的所有文档中的一个字段。我该怎么做。任何删除查询可以帮助我实现这一点。

解决方案

什么@backtrack告诉是真的,但后来有一个非常方便在弹性搜索中这样做的方式。
Elasticsearch将抽象出删除的内部复杂性。
您需要使用更新API来实现这一点 -

  curl -XPOST'localhost:9200 / test / type1 / 1 / _update'-d'{
script:ctx._source.remove(\name_of_field\)
}'
/ pre>

您可以找到更多文档这里


I need to remove a field in all the documents indexed to Elasticsearch . How can i do it. Will any of the delete queries help me achieve this.

解决方案

What @backtrack told is true , but then there is a very convenient way of doing this in Elasticsearch. Elasticsearch will abstract out the internal complexity of the deletion. You need to use update API to achieve this -

curl -XPOST 'localhost:9200/test/type1/1/_update' -d '{
    "script" : "ctx._source.remove(\"name_of_field\")"
}'

You can find more documentation here.

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

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