Hi all
We are using ElasticSearch to track a counter. When an update arrives in
our system we want to increment or decrement a field on a specific object.
It currently works well for removals, as we use the scripting functionality
to decrement the counter then remove the object if it hits zero.
However, for increments, we have the issue where if we issue an update for
an object that does exist, it works correctly (and increments the value);
however there seems to be no way to specify creating an object with that
name if it doesn't exist.
Our current workaround is to do a create (with the op_type=create argument)
before each update, but it seems like a waste to do two requests when it
would ideally be accomplished with only one.
Please see this gist with how we are performing the update and
create/update at the moment: https://gist.github.com/3246473
Does anyone have any thoughts on how it would be possible to do this update
and "create if not exists" in one request? The update endpoint doesn't
currently support PUT and I couldn't find anything in the docs.
Thanks
Chris