// Using callbacks (NodeJS or Web Browser)
  .collection('collection', 'index')
  .updateDocument('documentId', {title: 'foo', content: 'bar'}, function (error, result) {
    // result is a Document object

// Using promises (NodeJS)
  .collection('collection', 'index')
  .updateDocumentPromise('documentId', {title: 'foo', content: 'bar'})
  .then(result => {
    // result is a Document object
JSONObject newTitle = new JSONObject().put("title", "a shiny new title");

  .collection("collection", "index")
  .updateDocument("documentId", newTitle, new ResponseListener<Document>() {
    public void onSuccess(Document result) {
      // result is an updated Document object

    public void onError(JSONObject error) {
      // Handle error

use \Kuzzle\Kuzzle;
use \Kuzzle\Document;

$documentId = 'foobar';
$documentContent = [
  'newField' => 'foo'

$kuzzle = new Kuzzle('localhost');
$dataCollection = $kuzzle->collection('collection', 'index');

try {
  $document = $dataCollection->updateDocument($documentId, $documentContent);

  // $document instanceof Document
catch (ErrorException $e) {


Update parts of a document, by replacing some fields or adding new ones.
Note that you cannot remove fields this way: missing fields will simply be left unchanged.

updateDocument(documentId, content, [options], [callback])

documentIdstringUnique document identifier
contentJSON objectContent of the document to create
optionsJSON objectOptional parameters
callbackfunctionOptional callback


volatileJSON objectAdditional information passed to notifications to other usersnull
queuablebooleanMark this request as (not) queuabletrue
refreshstringIf set to wait_for, Kuzzle will wait the persistence layer indexation to return (available with Elasticsearch 5.x and above)undefined
retryOnConflictintNumber of retries to attempt before rejecting this update because of a cluster sync conflict0

Return value

Returns the Collection object to allow chaining.

Callback response

Resolves to an up-to-date Document object.