title: how to update nested document inside array in elasticsearch
body: <p>I have a following document </p>
  
  <pre><code>{
    "uuid": "123",
    "FirstName": "personFirstNmae",
    "LastName": "personLastName",
    "Inbox": {
      "uuid": "121",
      "messageList": [
        {
          "uuid": "321",
          "Subject": "subject1",
          "Delete": {
            "deleteStatus": 0,
            "deleteReason": 0
          }
        },
        {
          "uuid": "123",
          "Subject": "subject",
          "Delete": {
            "deleteStatus": 0,
            "deleteReason": 0
          }
        }
      ]
    }
  }
  </code></pre>
  
  <p>and here is the mapping </p>
  
  <pre><code>{
    "arteciatedb" : {
      "mappings" : {
        "directUser" : {
          "properties" : {
            "FirstName" : {
              "type" : "string",
              "store" : true
            },
            "Inbox" : {
              "type" : "nested",
              "include_in_parent" : true,
              "properties" : {
                "messageList" : {
                  "type" : "nested",
                  "include_in_parent" : true,
                  "properties" : {
                    "Delete" : {
                      "type" : "nested",
                      "include_in_parent" : true,
                      "properties" : {
                        "deleteReason" : {
                          "type" : "integer",
                          "store" : true
                        },
                        "deleteStatus" : {
                          "type" : "integer",
                          "store" : true
                        }
                      }
                    },
                    "Subject" : {
                      "type" : "string",
                      "store" : true
                    },
                    "uuid" : {
                      "type" : "string",
                      "store" : true
                    }
                  }
                },
                "uuid" : {
                  "type" : "string",
                  "store" : true
                }
              }
            },
            "Inbox.uuid" : {
              "type" : "string"
            },
            "LastName" : {
              "type" : "string",
              "store" : true
            },
  
            "uuid" : {
              "type" : "string",
              "store" : true
            }
          }
        }
      }
    }
  }
  </code></pre>
  
  <p>Now I want to update the value of <code>deleteStatus</code> from 0 to 1 this field is inside array nested document full path of this field is </p>
  
  <pre><code>Inbox.messageList.Delete.deleteStatus
  </code></pre>
  
  <p>i am trying to do it like this </p>
  
  <pre><code>     var params:java.util.Map[String,Object] = Maps.newHashMap();
       params.put("updateMap","1")
  
  val response = client.prepareUpdate("testdb", "directUser", directUserObj.getUuid)
      .setScript("ctx._source.Inbox.messageList.Delete.deleteStatus = updateMap",ScriptService.ScriptType.INLINE)
      .setScriptParams(params)
      .execute().actionGet();
  </code></pre>
  
  <p>but it gives the following error </p>
  
  <pre><code>org.elasticsearch.ElasticsearchIllegalArgumentException: failed to execute script
      at org.elasticsearch.action.update.UpdateHelper.prepare(UpdateHelper.java:202)
      at org.elasticsearch.action.update.TransportUpdateAction.shardOperation(TransportUpdateAction.java:176)
      at org.elasticsearch.action.update.TransportUpdateAction.shardOperation(TransportUpdateAction.java:170)
      at org.elasticsearch.action.support.single.instance.TransportInstanceSingleOperationAction$AsyncSingleAction$1.run(TransportInstanceSingleOperationAction.java:187)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
  Caused by: org.elasticsearch.script.groovy.GroovyScriptExecutionException: IllegalArgumentException[argument type mismatch]
      at org.elasticsearch.script.groovy.GroovyScriptEngineService$GroovyScript.run(GroovyScriptEngineService.java:278)
      at org.elasticsearch.action.update.UpdateHelper.prepare(UpdateHelper.java:198)
      ... 6 more
  </code></pre>
  
  <p>i have already added this line </p>
  
  <pre><code>script.engine.groovy.inline.update: on
  </code></pre>
  
  <p>in elasticsearch yml file 
  also when i try to do it like this </p>
  
  <pre><code>params.put("updateMap","12345")
  
  
  
  
       val response = client.prepareUpdate("testdb", "directUser", directUserObj.getUuid)
      .setScript("ctx._source.Inbox.uuid = updateMap",ScriptService.ScriptType.INLINE)
      .setScriptParams(params)
      .execute().actionGet();
  </code></pre>
  
  <p>then the value is updated without any error and then my doc becomes </p>
  
  <pre><code>{
    "uuid": "123",
    "FirstName": "personFirstNmae",
    "LastName": "personLastName",
    "Inbox": {
      "uuid": "12345",
      "messageList": [
        {
          "uuid": "321",
          "Subject": "subject1",
          "Delete": {
            "deleteStatus": 0,
            "deleteReason": 0
          }
        },
        {
          "uuid": "123",
          "Subject": "subject",
          "Delete": {
            "deleteStatus": 0,
            "deleteReason": 0
          }
        }
      ]
    }
  }
  </code></pre>
  
  <p>please guide me how can i update <code>deleteStatus</code> fields value from 0 to 1 and what am i doing wrong </p>