从 Elasticsearch 文档中删除字段 [英] Remove a field from a Elasticsearch document
本文介绍了从 Elasticsearch 文档中删除字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要删除索引到 Elasticsearch 的所有文档中的一个字段.我该怎么做?
I need to remove a field in all the documents indexed to Elasticsearch. How can I do it?
推荐答案
@backtrack 所说的是真的,但是在 Elasticsearch 中有一种非常方便的方法来做到这一点.Elasticsearch 会抽象出删除的内部复杂性.您需要使用更新 API 来实现这一点 -
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.
注意:从 Elastic Search 6 开始,您需要包含一个内容类型标头:
Note: As of Elastic Search 6 you are required to include a content-type header:
-H 'Content-Type: application/json'
这篇关于从 Elasticsearch 文档中删除字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文