Skip to content

Instantly share code, notes, and snippets.

@chrisalexander
Created August 3, 2012 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisalexander/3246473 to your computer and use it in GitHub Desktop.
Save chrisalexander/3246473 to your computer and use it in GitHub Desktop.
Script for doing an update - works if "test" object is already in the index, but not if it does not.
curl -XPOST localhost:9200/00000000-0000-0000-0000-000000000000/tag/test/_update -d '{ "script": "ctx._source.count += 1" }'
Workaround - create an object if it doesn't exist then do the update, every time:
curl -XPOST localhost:9200/00000000-0000-0000-0000-000000000000/tag/test/?op_type=create -d '{"count":0}'
curl -XPOST localhost:9200/00000000-0000-0000-0000-000000000000/tag/test/_update -d '{ "script": "ctx._source.count += 1" }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment