Skip to content

Instantly share code, notes, and snippets.

@brwe
Created October 14, 2014 07:27
Show Gist options
  • Save brwe/5ba123604c4cc0af9c3a to your computer and use it in GitHub Desktop.
Save brwe/5ba123604c4cc0af9c3a to your computer and use it in GitHub Desktop.
update script causing oom
import elasticsearch
es = elasticsearch.Elasticsearch()
for i in range(10000):
es.index(index="testidx", doc_type="doc", id=i, body= "{\"testfield\":\"a\"}")
es.indices.refresh()
for i in range(10000):
updateScript = "ctx._source.testfield += \" " + str(i) + "\""
updatebody = {"script": updateScript, "lang": "groovy"}
es.update(index="testidx", doc_type="doc", id=i, body= updatebody)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment