mReplace

Replaces multiple documents.

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

Arguments

Copied to clipboard!
String mReplace(
  String index,
  String collection,
  String documents,
  io.kuzzle.sdk.QueryOptions options
)
String mReplace(
  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 update
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 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

Copied to clipboard!
try {
  kuzzle.getDocument().create("nyc-open-data", "yellow-taxi", "some-id", "{}");
  kuzzle.getDocument().create("nyc-open-data", "yellow-taxi", "some-other-id", "{}");

  String newDocuments = "["
    + "{"
    + "     \"_id\": \"some-id\","
    + "     \"body\": { \"capacity\": 4 }"
    + "},"
    + "{"
    + "     \"_id\": \"some-other-id\","
    + "     \"body\": { \"capacity\": 4 }"
    + "}"
    + "]";

  String response = kuzzle.getDocument().mReplace(
    "nyc-open-data",
    "yellow-taxi",
    newDocuments
  );

  System.out.println(response);
} catch (KuzzleException e) {
  System.err.println(e.getMessage());
}