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.

mUpdate #

Updates multiple documents.

Returns a partial error (error code 206) if one or more documents can not be updated.

Conflicts may occur if the same document gets updated multiple times within a short timespan in a database cluster.

You can set the retryOnConflict optional argument (with a retry count), to tell Kuzzle to retry the failing updates the specified amount of times before rejecting the request with an error.

Arguments #

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

ArgumentTypeDescription
index
String
Index name
collection
String
Collection name
documents
String
A JSON string containing the documents to update
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)
retryOnConflict
int
(0)
The number of times the database layer should retry in case of version conflict

Return #

Returns a JSON string containing the updated documents.

Exceptions #

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

Usage #

String doc1 = "{\"capacity\": 4}";
String doc2 = "{\"capacity\": 7}";
try {
  kuzzle.getDocument().create("nyc-open-data", "yellow-taxi", "some-id", doc1);
  kuzzle.getDocument().create("nyc-open-data", "yellow-taxi", "some-other-id", doc2);
  String newDocuments = "["
    + "{"
    + "     \"_id\": \"some-id\","
    + "     \"body\": { \"category\": \"suv\" }"
    + "},"
    + "{"
    + "     \"_id\": \"some-other-id\","
    + "     \"body\": { \"category\": \"limousine\" }"
    + "}"
    + "]";
  String response = kuzzle.getDocument().mReplace(
    "nyc-open-data",
    "yellow-taxi",
    newDocuments
  );
  System.out.println(response);
  System.out.println("Success");
} catch (KuzzleException e) {
  System.err.println(e.getMessage());
}