例如,我想从索引中删除多个字段(“ person_full”,“ company_full”)。使用ES: 5.6.14
要删除一个字段->以下代码运行良好
POST firma-2019.04/_update_by_query?conflicts=proceed
{
"script": {
"source": "ctx._source.remove('person_full')",
"lang": "painless"
}
}
但是我想一次删除多个字段,因此此代码不起作用。
POST firma-2019.04/_update_by_query?conflicts=proceed
{
"script": {
"source": "ctx._source.remove('person_full','company_full')",
"lang": "painless"
}
}
预先感谢您的帮助
答案 0 :(得分:2)
下面的查询应该起作用:
select * from MIS_PERMAL.MV_INDEX_PERFORMANCE
where index_id = 1045 and YEAR(PRICE_DATE) = 2014
要删除更多字段,请在脚本中添加更多remove语句。
答案 1 :(得分:1)
您不想更新索引中的所有文档。想象一下,如果您有数百万,该脚本将更新所有文档。而是在尝试删除该字段之前添加其他检查以查看该字段是否存在。
下面将仅更新文档并删除person_full
或company_full
存在的字段。
POST firma-2019.04/_update_by_query?conflicts=proceed
{
"query": {
"bool": {
"should": [
{
"exists": {
"field": "person_full"
}
},
{
"exists": {
"field": "company_full"
}
}
]
}
},
"script": {
"source": "ctx._source.remove('person_full'); ctx._source.remove('company_full');",
"lang": "painless"
}
}