Python - Update nested object


#1

Hello,

I would like to use a Nested file for comments, but I can't find a way to update it as soon as someone post a comment.

Here is my mapping (using elasticsearch-dsl)

m = Mapping('comments'')

comments = Nested()
comments.field('author', Text())
comments.field('comment'', Text())
m.field('comments', comments)

m.save('search')

Now if I want to add a comment, it doesn't work:

es = Elasticsearch()
updated=es.update(index="search", doc_type="comments", id=43, body=
                       {
                        "script" : "ctx._source.comments.add(params.action)",
                        "params" :
                                { "action": {"author":"Antoine", "comment": "Hello"}
                                }
                       }) 

Is it the good way to do that ?

Thanks a lot!


(system) #2

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