Skolty
(Skolty)
June 10, 2017, 12:00am
1
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 :
Map<String, Object> params = new HashMap<>();
params.put("person", valueTest);
Script scriptTest = new Script(ScriptType.INLINE, "painless", "ctx._source.people.add(params.person);", params);
UpdateRequest bulkRequest = new UpdateRequest("index","type",id)
.script(scriptTest);
client.prepareUpdate("cityflow9","traject",id).setScript(scriptTest).execute().get();
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 ?
thiago
(Thiago Souza)
June 10, 2017, 12:16am
2
Can you show the code snippet that creates valueTest
?
Skolty
(Skolty)
June 10, 2017, 7:10am
3
Hello,
Thanks for replying !
Yes, of course, I try this :
And I try this as well :
Both give me the error
system
(system)
Closed
July 8, 2017, 1:54pm
5
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.