get

Gets a document.

Signature

Copied to clipboard!
std::string get(
    const std::string& index,
    const std::string& collection,
    const std::string& id);

std::string get(
    const std::string& index,
    const std::string& collection,
    const std::string& id,
    const kuzzleio::query_options& options);

Arguments

Argument Type Description
index
const std::string&
Index name
collection
const std::string&
Collection name
id
const std::string&
Document ID
options
kuzzleio::query_options*
Query options

options

Additional query options

Option Type
(default)
Description
queuable
bool

(true)
If true, queues the request during downtime, until connected to Kuzzle again

Return

A JSON string representing the document content.

Property Type Description
_source
object
Document content

Exceptions

Throws a kuzzleio::KuzzleException if there is an error. See how to handle errors.

Usage

Copied to clipboard!
try {
  kuzzle->document->create(
    "nyc-open-data",
    "yellow-taxi",
    "some-id",
    R"({"capacity": 4})");

  std::string response =
    kuzzle->document->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
      }
    }
  }
  */

  std::cout << "Success" << std::endl;
} catch (kuzzleio::KuzzleException& e) {
  std::cerr << e.what() << std::endl;
}