Updating an existing object in nested type


(Kalyan Srinivas) #1

Hi all
can somebody help me/guide me on how to update an existing nested type,i
could get to add new object to the nested array of objects but not update
an existing nested type
example document from ES
{
code:1234
blogname:my first blog
association:[{
code:234,
imagepath:"/web/z/l/test.jpg" },
code :546
imagepath:"Null"
]
so my question is how would i update my object with "code:546" path from
NULL to "/web/l/z/sample.jpg"

my update command looks like
{ "update" : { "_index" : "blog", "_type" : "posts", "_id" : "4611" } }
{ "script" : "WHAT CONDITION SHOULD GO HERE ", "params" : { "association":
[ {"code": 546, "path": "/web/l/z/sample.jpg" }]}}
How to get an existing object from array and update it..

Thanks
Kalyan

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/7135f190-b52a-4db4-9c03-3a5c7d5d3b5b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(Binh Ly-2) #2

Th script could iterate and do something like this for example:

{
"script": "for ($a: ctx._source.association) { if ($a.code == 546)
$a.imagepath='zzz'; }"
}

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/fa3e31ae-f5c0-42e3-b050-de5192e11add%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(Kalyan Srinivas) #3

Thank you so very much,this answer solved a lot of problems,YAY..!! Binh

On Wednesday, April 9, 2014 11:23:57 AM UTC-7, Binh Ly wrote:

Th script could iterate and do something like this for example:

{
"script": "for ($a: ctx._source.association) { if ($a.code == 546)
$a.imagepath='zzz'; }"
}

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/7307cae1-c96b-4f65-8433-26dd885d496b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(system) #4