get

Gets a document.

Arguments

Copied to clipboard!
String get(
  String index,
  String collection,
  String id,
  io.kuzzle.sdk.QueryOptions options
)
String get(
  String index,
  String collection,
  String id
)

Argument Type Description
index
String
Index name
collection string Collection name
id
String
Document ID
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

Return

Returns a JSON string containing the document.

Exceptions

Throws a io.kuzzle.sdk.KuzzleException if there is an error. See how to handle error.

Usage

Copied to clipboard!
String doc = "{\"capacity\": 4}";

try {
  kuzzle.getDocument().create("nyc-open-data", "yellow-taxi", "some-id", doc);

  String response = kuzzle.getDocument().get("nyc-open-data", "yellow-taxi", "some-id");
  /*
  {
    "_index":"nyc-open-data",
    "_type":"yellow-taxi",
    "_id":"some-id",
    "_version":1,
    "found":true,
    "_source":{
      "capacity":4,
      "_kuzzle_info":{
      "author":"-1",
      "createdAt":1538402859880,
      "updatedAt":null,
      "updater":null,
      "active":true,
      "deletedAt":null
      }
    }
  }
  */

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