SDK
SDK Java v1.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.

This SDK has been deprecated because of stability issues. It is not advised to use it in a production environment.

mCreate #

Creates multiple documents.

Throws a partial error (error code 206) if one or more documents creations fail.

Arguments #

Copied to clipboard!
String mCreate(
  String index,
  String collection,
  String documents,
  io.kuzzle.sdk.QueryOptions options
)
String mCreate(
  String index,
  String collection,
  String documents
)

Argument Type Description
index
String
Index name
collection
String
Collection name
documents
String
A JSON string containing the documents to create
options
io.kuzzle.sdk.QueryOptions
Query options

options #

Additional query options

Option Type
(default)
Description
queuable
boolean

(true)
If true, queues the request during downtime, until connected to Kuzzle again
refresh
String

("")
If set to wait_for, waits for the change to be reflected for search (up to 1s)

Return #

Returns an JSON string containing the created documents.

Exceptions #

Throws a io.kuzzle.sdk.KuzzleException if there is an error. See how to handle error.

Usage #

Copied to clipboard!
String documents = "["
  + "   {"
  + "       \"_id\": \"some-id\","
  + "       \"body\": { \"capacity\": 4 }"
  + "   },"
  + "   {"
  + "       \"body\": { \"this\": \"document id is auto-computed\" }"
  + "   }"
  + "]";
try {
  String response = kuzzle.getDocument().mCreate(
    "nyc-open-data",
    "yellow-taxi",
    documents
  );
  System.out.println(response);
  /*
  [
    {
    "_id":"some-id",
    "_source":{
      "_kuzzle_info":{
        "active":true,
        "author":"-1",
        "updater":null,
        "updatedAt":null,
        "deletedAt":null,
        "createdAt":1538470871764
      },
      "capacity":4
    },
    "_index":"nyc-open-data",
    "_type":"yellow-taxi",
    "_version":1,
    "result":"created",
    "_shards":{
      "total":2,
      "successful":1,
      "failed":0
    },
    "created":true,
    "status":201
    },
    {
    "_id":"AWY0AoLgKWETYfLdcMat",
    "_source":{
      "_kuzzle_info":{
        "active":true,
        "author":"-1",
        "updater":null,
        "updatedAt":null,
        "deletedAt":null,
        "createdAt":1538470871764
      },
      "this":"document id is auto-computed"
    },
    "_index":"nyc-open-data",
    "_type":"yellow-taxi",
    "_version":1,
    "result":"created",
    "_shards":{
      "total":2,
      "successful":1,
      "failed":0
    },
    "created":true,
    "status":201
    }
  ]
  */
  System.out.println("Success");
} catch (KuzzleException e) {
  System.err.println(e.getMessage());
}