How do i make a single update request on ES having both “script” and “doc”..?

前端 未结 1 859
星月不相逢
星月不相逢 2021-01-27 11:20

My \'doc\' request:

POST test_v2/_update/Z_nM_2wBjkGOA-r6ArOb
{
  \"doc\": {
    \"CD\": {
      \"middle\": \"prakash\",
      \"first\": \"raj\"
    }
  },
           


        
1条回答
  •  别那么骄傲
    2021-01-27 11:41

    ctx._source['CD']=params.object1 ---> will update or add new field

    POST test3/_update/30RaAG0BY3127H1HaOEv
    {
      "scripted_upsert":true,
      "script": {
        "lang": "painless",
        "inline": "ctx._source['CD']=params.object1; if(!ctx._source.containsKey('comments')){ctx._source['comments']=[]}ctx._source.comments.add(params.object)",
        "params": {
          "object": {
            "model": "tata nano",
            "value": "2"
          },
          "object1": {
          "middle": "prakash1",
          "first": "raj1"
        }
        }
      },
      "upsert" : {}
    }
    

    0 讨论(0)
提交回复
热议问题