SDK Java v2.x

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.

mCreateDocument #

Create the input Documents.

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

Arguments Type Description
documents Document[] Array of Document to create
options JSON Object Optional parameters
callback function Optional callback

Options #

Option Type Description Default
queuable boolean Make this request queuable or not true

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 some documents could not be created.

Usage #

Copied to clipboard!
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};
  .collection("collection", "index")
  .mCreateDocument(documents, new ResponseListener<JSONObject>() {
    public void onSuccess(JSONObject object) {
      // callback called once the mCreate operation has completed
      // => the result is a JSON object containing the raw Kuzzle response
    public void onError(JSONObject error) {
      // Handle error

Callback response:

Copied to clipboard!
  "hits": [{ "first": "document" }, { "second": "document" }],
  "total": 2