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.

mCreateOrReplace #

Creates or replaces multiple documents.

Throws a partial error (error code 206) if one or more document creations/replacements fail.

Arguments #

String mCreateOrReplace(
  String index,
  String collection,
  String documents,
  io.kuzzle.sdk.QueryOptions options
)
String mCreateOrReplace(
  String index,
  String collection,
  String documents
)

ArgumentTypeDescription
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

OptionType
(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 #

String documents = "["
  + "   {"
  + "       \"_id\": \"some-id\","
  + "       \"body\": { \"capacity\": 4 }"
  + "   },"
  + "   {"
  + "       \"_id\": \"some-other-id\","
  + "       \"body\": { \"capacity\": 4 }"
  + "   }"
  + "]";
try {
  String response = kuzzle.getDocument().mCreateOrReplace(
    "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":1538552685790
      },
      "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":"some-other-id",
    "_source":{
      "_kuzzle_info":{
      "active":true,
      "author":"-1",
      "updater":null,
      "updatedAt":null,
      "deletedAt":null,
      "createdAt":1538552685790
      },
      "capacity":4
    },
    "_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());
}