SDK
SDK Java v3.x
2

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

mCreateOrReplace #

Creates or replaces multiple documents.


Arguments #

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

public CompletableFuture<ConcurrentHashMap<String, ArrayList<Object>>> mCreateOrReplace(
      final String index,
      final String collection,
      final ArrayList<ConcurrentHashMap<String, Object>> documents,
      final Boolean waitForRefresh)
throws NotConnectedException, InternalException
Arguments Type Description
index
String
Index
collection
String
Collection
documents
ArrayList<ConcurrentHashMap<String, Object>>
ArrayList containing the documents to create
waitForRefresh
Boolean
If set to true, Kuzzle will wait for the persistence layer to finish indexing

documents #

Each document has the following properties:

Arguments Type Description
_id
String
Optional document ID. Will be auto-generated if not defined.
body
ConcurrentHashMap<String, Object>
Document body

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>
Created document
_id
String
ID of the newly created 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("Agent", "Smith");
body2.put("Gordon", "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()
  .mCreateOrReplace("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=201
      },
      {
        result=created,
        _source=
          {
            Gordon=Freeman,
            _kuzzle_info={createdAt=1582892842099, author=-1}
          },
        _id=some-id2,
        _version=1,
        status=201
      }
    ],
    errors=[]
  }
*/