Hi,
I'm having a bit of an issue getting a script working; basically, the script is intended to add a nested item to an existing doc.
To repro, I created an index with this mapping:
curl -XPUT 'http://localhost:9200/nsttest' 
{
"mappings": 
    { "test": 
        { "properties": 
                { 
                "prntId" : {"type": "keyword",  "doc_values": true },
		"kids" : {
		        "type": "nested", 
		        "properties": { 
			                "ctxt": {"type": "keyword",  "doc_values": true },
			                "tkn": {"type": "keyword",  "doc_values": true }  
			                } 
                                }
                        } 
                }  
        } 
}
And added a single doc:
curl -XPUT 'http://localhost:9200/nsttest/test/abc'
{
  "prntId" : "abc"
}
curl -XPOST 'http://localhost:9200/nsttest/test/abc/_update'
{
	"script": 
	{ 
		"inline" :  "if (ctx._source.kids == null || ctx._source.kids.size() == 0){ ctx._source.kids = params.kid}  else {ctx._source.kids += params.kid } ", 
		"lang": "painless",
		"params": {"kid":  [{"ctxt" : "xs123", "tkn" : "4eef3f46-5469-42d4-91c2-371748d0ee13"}] }
	}
}
curl -XPOST 'http://localhost:9200/nsttest/test/abc/_update/pretty'
{
	"script": 
	{ 
		"inline" :  "if (ctx._source.kids == null || ctx._source.kids.size() == 0){ ctx._source.kids = params.kid}  else {ctx._source.kids += params.kid } ", 
		"lang": "painless",
		"params": {"kid":  [{"ctxt" : "xs1234", "tkn" : "5eef3f46-5469-42d4-91c2-371748d0ee13"}] }
	}
}
I have tried the params with and without the square brackets, and basically many variations, and it will work updating a doc for the first time, but not thereafter - i.e. "ctx._source.kids += params.kid " always fails...
Here is the error I get:
{
  "error" : {
    "root_cause" : [
      {
        "type" : "remote_transport_exception",
        "reason" : "[bpQJEwv][127.0.0.1:9300][indices:data/write/update[s]]"
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "failed to execute script",
    "caused_by" : {
      "type" : "script_exception",
      "reason" : "runtime error",
      "caused_by" : {
        "type" : "class_cast_exception",
        "reason" : "Cannot apply [+] operation to types [java.util.ArrayList] and [java.util.HashMap]."
      },
      "script_stack" : [
        "ctx._source.kids += params.kid } ",
        "                          ^---- HERE"
      ],
      "script" : "if (ctx._source.kids == null || ctx._source.kids.size() == 0){ ctx._source.kids = params.kid}  else {ctx._source.kids += params.kid } ",
      "lang" : "painless"
    }
  },
  "status" : 400
}
Anyone have any ideas or pointers?
Thanks in advance!
Paul
 Obvious in retrospect, can't believe I didn't see it!