elasticsearch 数组内部的弹性update_by_query

uajslkp6  于 2023-10-17  发布在  ElasticSearch
关注(0)|答案(1)|浏览(141)

我有一个数组,看起来像这样:

"_source": {
    "dateCreated": "2023-07-12",
    "sources": [
      {
        "1": null,
        "lastUpdateDate": "2023-08-10T11:12:36.9848505",
        "postedDate": "2023-08-10T10:38:57.9440773"

如何从sources数组更新postedDate?

我已经设法用这个查询更新了dateCreated:

POST index/_update_by_query
{
  "script": {
    "source": "ctx._source.dateCreated='2023-07-12'",
    "lang": "painless"
  },
  "query": {
    "terms": {
      "_id": [
"12345"
]
    }
  }
}
anauzrmj

anauzrmj1#

你可以这样做,通过访问数组:

ctx._source.sources[0].postedDate='2023-07-12'

相关问题