SDK
SDK Java v3.x
2

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

createOrReplace #

Creates a new document in the persistent data storage, or replaces its content if it already exists.


Arguments #

public CompletableFuture<ConcurrentHashMap<String, Object>> createOrReplace(
      final String index,
      final String collection,
      final String id,
      final ConcurrentHashMap<String, Object> document)
throws NotConnectedException, InternalException

public CompletableFuture<ConcurrentHashMap<String, Object>> createOrReplace(
      final String index,
      final String collection,
      final String id,
      final ConcurrentHashMap<String, Object> document,
      final Boolean waitForRefresh)
throws NotConnectedException, InternalException
ArgumentsTypeDescription
index
String
Index
collection
String
Collection
id
String
Document ID
document
ConcurrentHashMap<String, Object>
Document content
waitForRefresh
Boolean
If set to true, Kuzzle will wait for the persistence layer to finish indexing

Return #

A ConcurrentHashMap which has the following properties:

PropertyTypeDescription
_source
ConcurrentHashMap
Document content
_id
String
ID of the document
_version
Integer
Version of the document in the persistent data storage

Usage #

ConcurrentHashMap<String, Object> document = new ConcurrentHashMap<>();
document.put("firstname", "John");
ConcurrentHashMap<String, Object> result = kuzzle
  .getDocumentController()
  .createOrReplace("nyc-open-data", "yellow-taxi", "some-id", document)
  .get();
/*
  {
    _source=
      {
        firstname=John,
        _kuzzle_info={ 
          createdAt=1582892323254, 
          author=-1, 
          updatedAt=1582892323254, 
          updater=-1
        }
      },
  _id=some-id,
  _version=1
  }
 */