Pyes API/documentation on using Update API


(es_learner) #1

So I read up a bit more on the Update API - http://www.elasticsearch.org/guide/reference/api/update.html

But I'm lost in finding pyes API docs for the same. The above link did mention 'update operation supports similar parameters as the index API' but how I do I pass in the ctx and params used in the curl examples.

Any pointers please?


(Radu Gheorghe) #2

Hey,

AFAIK, there is an "update" function in pyes, but it's not using the Update
API. Here's the relevant snip from

def update(self, extra_doc, index, doc_type, id, querystring_args=None,
           update_func=None, attempts=2):
    """
    Update an already indexed typed JSON document.

    The update happens client-side, i.e. the current document is retrieved,
    updated locally and finally pushed to the server. This may repeat up to
    ``attempts`` times in case of version conflicts.

    :param update_func: A callable ``update_func(current_doc, extra_doc)``
        that computes and returns the updated doc. Alternatively it may
        update ``current_doc`` in place and return None. The default
        ``update_func`` is ``dict.update``.

    :param attempts: How many times to retry in case of version conflict.
    """

So you can use that, but I think it would be risky to use it if you have
multiple processes/threads.

On Saturday, September 29, 2012 1:50:58 AM UTC+3, es_learner wrote:

So I read up a bit more on the Update API -
http://www.elasticsearch.org/guide/reference/api/update.html

But I'm lost in finding pyes API docs for the same.

Any pointers please?

--


(system) #3