I'm trying to update a partial nested object with a script. But what I have written is incorrect.
I've this object:
{
"_index" : "test_7",
"_type" : "testField",
"_id" : "1",
"_version" : 1,
"found" : true,
"_source" : {
"view" : {
"hit" : 3,
"pages" : [
{
"name" : "A",
"hit" : 1
},
{
"name" : "B",
"hit" : 1
},
{
"name" : "C",
"hit" : 1
}
]
}
}
}
I would like add 3 hits on a page.
With the existing page named "B":
{
"view" : {
"hit" : 6,
"pages" : [
{
"name" : "A",
"hit" : 1
},
{
"name" : "B",
"hit" : 4
},
{
"name" : "C",
"hit" : 1
}
]
}
}
With a new page named "D":
{
"view" : {
"hit" : 6,
"pages" : [
{
"name" : "A",
"hit" : 1
},
{
"name" : "B",
"hit" : 1
},
{
"name" : "C",
"hit" : 1
},
{
"name" : "D",
"hit" : 3
}
]
}
}
Please can you tell me how write the HTTP request? Moreover where can I read more documentation about "ctx._source"?
Thanks.