Nested Object insert/update


(Get2sada) #1

Hi Everyone:

Below nested update does not insert a new nested object in the array, Notice the added brackets [ ]

curl -XPOST 'http://localhost:9200/v2/Test/cd196e01/_update' -d'{"script":"ctx._source.Code += Code",
"params":{"Code":[{
"Family":"Family",
"Code":"Raw",
"Code":12345,
"Role":"",
"Rank":4,
"Description":"Some updates",
"SourceType":"human",
"SourceSequence":1,
"SourceValue":"some value",
"Status":"active"
}]
}
}'

Getting error msg:

{"error":"ElasticsearchIllegalArgumentException[failed to execute script]; nested: GroovyScriptExecutionException[ClassCastException[java.util.HashMap cannot be cast to java.util.Map$Entry]

However, removing the brackets [ ] will update the existing nested object. Need to insert nested object instead.

Any help is much appreciated !!

Thank You


(Nelson Matias) #2

Hi, did u manage to fix that?