我已经在ES中使用用户实体设置了静态索引
{
"mappings": {
"_default_": {
"dynamic": "false"
},
"user": {
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"age": {
"type": "integer"
}
}
}
}
}
当我发布的文档中的字段比索引中的字段多时,会将其保存到ES中。
它不会更新映射,但会保存新字段。
有没有一种方法可以删除不在索引中的字段?
我不想存储未索引的字段。
最佳答案
在映射中,您需要使用 _source
filtering:
{
"mappings": {
"_default_": {
"dynamic": "false"
},
"user": {
"_source": {
"includes": [
"id","name","age"
]
},
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"age": {
"type": "integer"
}
}
}
}
}
关于elasticsearch - ElasticSearch-如何不存储未在静态索引中定义的字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39118869/