有个人长的像洋葱,走着走着就哭了…….

es中nested结构reindex时如何舍弃源index中的某个属性?

Elasticsearch | 作者 ifree_zm | 发布于2021年09月10日 | 阅读数:1104

假设这是我的结构
{
"mappings": {
"properties":{
"group": {"type": "text"},
"user":{
"properties":{
"id": {"type": "keyword"},
"name":{"type": "text"},
"age":{ "type": "short"},
"order":{
"type": "nested",
"properties":{
"orderNo": {"type": "text"},
"product":{
"properties":{
"proName": {"type":"text"},
"supplier":{
"type":"nested",
"properties":{
"suName": {"type":"text"},
"suAddress": {"type":"text"}
}
}
}
}
}

}
}

}
}
}
}
如果在reindex命令时 想要剔除user.name 属性应该如何做?
我试过这段代码没有作用:
{
"source": {
"index": "test_index2"
},
"dest": {
"index": "test_index3"
},
"script": {
"source": "ctx._source.user.remove(\"age\")"
}
}
另外nested结构中的属性如何剔除呢?比如order.orderNo
已邀请:

Charele - Cisco4321

赞同来自:

"script": {
"source": "ctx._source.remove(\"user.age\")"
}
 
 

God_lockin

赞同来自:

nested型的数据在script里不能解析成列表/对象的,直接删里面的子属性可能不行,最好就在入库的时候做删除

要回复问题请先登录注册