SDK
SDK Java v3.x
2

This SDK is deprecated. We recommend to use the Kuzzle SDK-JVM.
A migration guide is available here

mUpdate #

Updates multiple documents.


Arguments #

Copied to clipboard!
public CompletableFuture<ConcurrentHashMap<String, ArrayList<Object>>> mUpdate(
      final String index,
      final String collection,
      final ArrayList<ConcurrentHashMap<String, Object>> documents)
throws NotConnectedException, InternalException

public CompletableFuture<ConcurrentHashMap<String, ArrayList<Object>>> mUpdate(
      final String index,
      final String collection,
      final ArrayList<ConcurrentHashMap<String, Object>> documents,
      final UpdateOptions options)
throws NotConnectedException, InternalException
Arguments Type Description
index
String
Index
collection
String
Collection
documents
ArrayList<ConcurrentHashMap<String, Object>>
ArrayList containing the documents to update
options
UpdateOptions

(null)
Query options

documents #

Each document has the following properties:

Arguments Type Description
_id
String
Document ID
body
ConcurrentHashMap<String, Object>
Document body

options #

An UpdateOptions object.

The mUpdate method takes into account those following arguments:

Arguments Type Description
retryOnConflict
Integer
(optional)
The number of times the database layer should retry in case of version conflict
waitForRefresh
Boolean
(optional)
If set to true, Kuzzle will wait for the persistence layer to finish indexing

Return #

A ConcurrentHashMap<String, ArrayList<Object>> which has a successes and errors ArrayList<Object>: Each created document is an object of the successes array with the following properties:

Property Type Description
_source
ConcurrentHashMap<String, Object>
Updated document
_id
String
ID of the updated document
_version
Integer
Version of the document in the persistent data storage

Each errored document is an object of the errors array with the following properties:

Property Type Description
document
ConcurrentHashMap<String, Object>
Document that causes the error
status
Integer
HTTP error status
reason
String
Human readable reason

Usage #

Copied to clipboard!
ConcurrentHashMap<String, Object> document1 = new ConcurrentHashMap<>();
ConcurrentHashMap<String, Object> document2 = new ConcurrentHashMap<>();
ConcurrentHashMap<String, Object> body = new ConcurrentHashMap<>();
ConcurrentHashMap<String, Object> body2 = new ConcurrentHashMap<>();
body.put("name", "Smith");
body2.put("name", "Freeman");
document1.put("_id", "some-id");
document1.put("body", body);
document2.put("_id", "some-id2");
document2.put("body", body2);
final ArrayList<ConcurrentHashMap<String, Object>> documents = new ArrayList<>();
documents.add(document1);
documents.add(document2);
ConcurrentHashMap<String, ArrayList<Object>> result = kuzzle
  .getDocumentController()
  .mUpdate("nyc-open-data", "yellow-taxi", documents)
  .get();
/*
result =
  {
    successes=
    [
      {
        result=created,
        _source=
          {
            Agent=Smith,
            _kuzzle_info={createdAt=1582892842099, author=-1}
          },
        _id=some-id,
        _version=1,
        status=200
      },
      {
        result=created,
        _source=
          {
            Gordon=Freeman,
            _kuzzle_info={createdAt=1582892842099, author=-1}
          },
        _id=some-id2,
        _version=1,
        status=200
      }
    ],
    errors=[]
  }
*/