VSToolsPath
答案 0 :(得分:1)
您可以根据您的要求使用scripted update
(documentation link)。
在hobbiles
中查询添加值{
"script" : {
"source": "ctx._source.others.hobbies.add(params.hobby)",
"lang": "painless",
"params" : {
"hobby": "reading books"
}
}
}
在其他人中添加新字段
{
"script": {
"source": "ctx._source.others.location = 'value_of_new_field'",
"lang": "painless"
}
}
从业余爱好中删除板球
{
"script" : {
"source": "int index = ctx._source.others.hobbies.indexOf(params.remove_string); if(index != -1){ctx._source.others.hobbies.remove(index);}",
"lang": "painless",
"params" : {
"remove_string" : "cricket"
}
}
}
UPDATE-1 根据以下评论中的要求,可以添加数组字段。
添加数组字段
{
"script": {
"source": "ctx._source.extra.location = []",
"lang": "painless"
}
}