Java API UpdateArray

Hi Guys !

I have a document which contains an array of JSONObject.

When I add a JSONObject in my array from Sense like this, it works fine :

[quote] POST index/type/1/_update
{
"script" : {
"inline": "ctx._source.people.add(params.person)",
"lang": "painless",
"params" : {
"person" : {
"field" : "test"
}
}
}
}
[/quote]

But when I'm trying to add throw the Java Api with this code :

I got the following error : java.io.IOException: can not write type [class org.json.JSONObject]

I tried to replace the JSONObject with a XContentBuilder but the same exception is throwing...

Can anyone has an explenation or an idea how I can fix this ?

Can you show the code snippet that creates valueTest?

Hello,

Thanks for replying !

Yes, of course, I try this :

And I try this as well :

Both give me the error :frowning:

Try with a HashMap

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.