Elasticsearch Updating nested objects

扶醉桌前 提交于 2019-12-06 05:06:18

You can try to use Partial Updates and some scripting language. The script would look more or less (here in groovy) like:

if (ctx._source.links != null) {
    for (item in ctx._source.links) { 
        if (item.note_link_id == params.link_id_param) {
            item.comment = params.comment_param;
        }
    }
}

Then use the script with Update API:

POST /index_name/type_name/document_id/_update
{
   "script" : "...",
   "params" : {
      "link_id_param" : "2",
      "comment_param" : "blja blja blja"
   }
}

Just remember that documents in Elasticsearch are immutable so technically the whole document will be reindexed.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!