[弹性搜索中的$ pull和$ push查询

问题描述 投票:0回答:1

MongoDB支持$ pull和$ push查询以将元素删除或添加到数组中。弹性搜索中是否可以存在用于添加或删除数组元素的类似查询。

elasticsearch
1个回答
0
投票

您可以为此使用脚本,并使用update_by_query API进行更新。

{ 
    "script": {
    "inline": "ctx._source.<name_of_array>.add(params.<name_of_variable>)",
    "params": {"<name_of_variable>": 1}
  },
  "query": {
    // specify the query if want to apply on filtered documents.
}
© www.soinside.com 2019 - 2024. All rights reserved.