身安不如心安,屋宽不如心宽 。

elastic如何删除不需要的字段

Elasticsearch | 作者 百衲本 | 发布于2018年07月24日 | 阅读数:2342


SHY[N}7]KQR`IVEWJ[[86S.png


如图,有些字段对我来说没有使用意义,如何可以删除?
已邀请:

rochy - rochy_he

赞同来自: rockybean

这个没有办法删除,除非重建索引,如果不使用可以不用理会。

laoyang360 - 《一本书讲透Elasticsearch》作者,Elastic认证工程师 [死磕Elasitcsearch]知识星球地址:http://t.cn/RmwM3N9;微信公众号:铭毅天下; 博客:https://elastic.blog.csdn.net

赞同来自:

方式一:
curl -XPOST 'localhost:9200/test/type1/1/_update' -d '{
"script" : "ctx._source.remove(\"name_of_field\")"
}'
方式二:
步骤1:
POST _reindex
{
"source": {
"index": "old_index"
},
"dest": {
"index": "new_index"
},
"script": {
"inline": """
if (ctx._type == "bad_type") {
ctx._source.remove("bad_field");
}
"""
}
}
步骤2:
POST /_aliases
{
"actions": [
{
"add": {
"index": "new_index",
"alias": "old_index"
}
},
{
"remove_index": {
"index": "old_index"
}
}
]
}

zqc0512 - andy zhou

赞同来自:

新索引的时候不要这个字段就行了,要不重新建立索引 用别名

要回复问题请先登录注册