Skip to content

Commit

Permalink
Added partial_update method.
Browse files Browse the repository at this point in the history
  • Loading branch information
lextoumbourou committed Jan 30, 2015
1 parent 4ab3f89 commit 2a50cb1
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions txes2/elasticsearch.py
Expand Up @@ -668,6 +668,27 @@ def update_settings(self, index, settings):
d = self._send_request('PUT', path, body=settings)
return d

def partial_update(
self, index, doc_type, id, doc=None, script=None,
params=None, upsert=None, **query_params
):
"""Partially update a document with a script."""
if doc is None and script is None:
raise exceptions.InvalidQuery("script or doc can not both be None")

if doc is None:
cmd = {'script': script}
if params:
cmd["params"] = params
if upsert:
cmd["upsert"] = params
else:
cmd = {'doc': doc}

path = self._make_path(index, doc_type, id, '_update')
d = self._send_request('POST', path, cmd, params=query_params)
return d

@property
def servers(self):
"""Return a list of servers available for connections."""
Expand Down

0 comments on commit 2a50cb1

Please sign in to comment.