SDK
SDK Android v3.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

updateDocument #

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]) #

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

Options #

OptionTypeDescriptionDefault
volatileJSON objectAdditional information passed to notifications to other usersnull
queuablebooleanMake this request queuable or nottrue
refreshstringIf set to wait_for, Kuzzle will wait the persistence layer to finish indexing (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 #

Returns an up-to-date Document object.

Usage #

JSONObject newTitle = new JSONObject().put("title", "a shiny new title");
kuzzle
  .collection("collection", "index")
  .updateDocument("documentId", newTitle, new ResponseListener<Document>() {
    @Override
    public void onSuccess(Document result) {
      // result is an updated Document object
    }
    @Override
    public void onError(JSONObject error) {
      // Handle error
    }
  });