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.

mReplaceDocument #

Replace the provided Documents.


mReplaceDocument(documents, [options], [callback]) #

ArgumentsTypeDescription
documentsDocument[]Array of Document to replace
optionsJSON ObjectOptional parameters
callbackfunctionOptional callback

Options #

OptionTypeDescriptionDefault
queuablebooleanMake this request queuable or nottrue

Return Value #

Returns the Collection object to allow chaining.


Callback Response #

Returns a JSON object containing the raw Kuzzle response. Can return a 206 partial error in cases where documents could not be replaced.

Usage #

Document firstDocument = new Document(collection, "doc1");
firstDocument.setContent("title", "foo");
firstDocument.setContent("content", "bar");
Document secondDocument = new Document(collection, "doc2");
secondDocument.setContent("title", "foo");
secondDocument.setContent("content", "bar");
Document[] documents = new Document[]{firstDocument, secondDocument};
kuzzle
  .collection("collection", "index")
  .mReplaceDocument(documents, new ResponseListener<JSONObject>() {
    @Override
    public void onSuccess(JSONObject object) {
      // callback called once the mReplace operation has completed
      // => the result is a JSON object containing the raw Kuzzle response
    }
    @Override
    public void onError(JSONObject error) {
      // Handle error
    }
  });

Callback response:

{
  "hits": [{ "first": "document" }, { "second": "document" }],
  "total": 2
}