Elasticsearch: remove/update field inside nested object

后端 未结 4 1867
借酒劲吻你
借酒劲吻你 2021-01-12 18:36
{
  \"_index\" : \"test\",
  \"_type\" : \"test\",
  \"_id\" : \"1212\",
  \"_version\" : 5,
  \"found\" : true,
  \"_source\" : {
    \"count\" : 42,
    \"list_dat         


        
4条回答
  •  花落未央
    2021-01-12 18:50

    I was getting error [UpdateRequest] unknown field [params] as I was using the latest version of ElasticSearch (7.9.0.), seems like the syntax is changed a bit.

    Following should work for newer versions of ElasticSearch:

    $ curl -XPOST 'localhost:9200//_update/1212'
    {
      "script": {
        "source": "ctx._source.list_data.removeIf(list_item -> list_item.list_id == params.remove_id);",
        "params": {
          "remove_id": 122
        }
      }
    }
    

提交回复
热议问题