SDK
SDK Java v2.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.

Document #

Kuzzle handles two types of documents: realtime messages and stored documents. Document is the object representation of one of these document types.


Document(Collection, [documentId], [content]) #

ArgumentsTypeDescription
CollectionobjectAn instantiated Collection object
contentJSON ObjectInitializes this document with the provided content
documentIdstringID of an existing document.

Note: this constructor won't make any call to Kuzzle. When providing only a document ID, the refresh method should be called to retrieve the corresponding document content.


Properties #

Property nameTypeDescriptionget/set
collectionstringThe collection associated to this documentget
contentJSON ObjectThe content of the documentget/set
headersJSON ObjectCommon headers for all sent documents.get/set
idstringUnique document identifierget/set
metaJSON ObjectDocument metadataget
versionintegerCurrent document versionget

Notes:

  • setting a new value to the content property is equivalent to calling setContent(data, false)
  • setting a new value to the id property will force this value for this document
  • the headers property is inherited from the provided Collection object and can be overrided

Usage #

Document document = new Document(collection);
Document document = new Document(collection, "id");
JSONObject content = new JSONObject();
content.put("content", "some content");
Document document = new Document(collection, content);
Document document = new Document(collection, "id", content);