Merge some of update by document and script

These share many of the same options so it makes sense to merge them.
This also adds support for things like _retry_on_conflict and _routing to
updates by scripts.

Closes #628
Closes #627