Skip to content

Commit

Permalink
Support querystring_args in update method
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Holm committed Oct 23, 2013
1 parent 4ba7d98 commit 0b4d428
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pyes/es.py
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,10 @@ def get_file(self, index, doc_type, id=None):
return data['_name'], base64.standard_b64decode(data['content'])

def update(self, index, doc_type, id, script=None, lang="mvel", params=None, document=None, upsert=None,
model=None, bulk=False):
model=None, bulk=False, querystring_args=None):
if querystring_args is None:
querystring_args = {}

body = {}
if script:
body.update({"script": script, "lang": lang})
Expand All @@ -1096,13 +1099,18 @@ def update(self, index, doc_type, id, script=None, lang="mvel", params=None, doc

if bulk:
cmd = {"update": {"_index": index, "_type": doc_type, "_id": id}}
if 'routing' in querystring_args:
cmd['_routing'] = querystring_args['routing']
if 'percolate' in querystring_args:
cmd['percolate'] = querystring_args['percolate']

command = "%s\n%s" % (json.dumps(cmd, cls=self.encoder), json.dumps(body, cls=self.encoder))
self.bulker.add(command)
return self.flush_bulk()

path = make_path(index, doc_type, id, "_update")
model = model or self.model
return model(self, self._send_request('POST', path, body))
return model(self, self._send_request('POST', path, body, querystring_args))

def update_by_function(self, extra_doc, index, doc_type, id, querystring_args=None,
update_func=None, attempts=2):
Expand Down

0 comments on commit 0b4d428

Please sign in to comment.