弹性搜索

时间:2018-05-09 09:17:46

标签: elasticsearch

我需要更新elasticsearch 5.X

中的嵌套文档(批量)

条件

  1. 我将拥有多个具有相同groupid的文档。
  2. 我想更新文档的groupname,其中包含了groupid 244
  3. 我必须批量更新它们。
  4. 例如:{ "hits": { "hits": [{ "_index": "myindex", "_id": "1", "_source": { "ticketdesc": [{ "groupid": 244, "groupname": "Fire and run" }] } }, { "_index": "myindex", "_id": "2", "_source": { "ticketdesc": [{ "groupid": 244, "groupname": "Fire and run" }] } }, { "_index": "myindex", "_id": "3", "_source": { "ticketdesc": [{ "groupid": 244, "groupname": "Fire and run" }] } }, { "_index": "myindex", "_id": "4", "_source": { "ticketdesc": [{ "groupid": 245, "groupname": "Fire and run" }] } } ] } }

    提前致谢

1 个答案:

答案 0 :(得分:1)

您可以轻松地使用update by query API

POST myindex/_update_by_query
{
  "query": {
    "term": {"groupid": 245}
  },
  "script": {
    "source": "ctx._source.groupname = 'New name' "
  }
}