SDK
SDK Golang v3.x
2

Get #

Gets a document.

Arguments #

Get(
  index string,
  collection string,
  _id string,
  options types.QueryOptions) (json.RawMessage, error)

ArgumentTypeDescription
index
string
Index name
collection
string
Collection name
id
string
Document ID
options
types.QueryOptions
A struct containing query options

options #

Additional query options

OptionType
(default)
Description
Queuable
bool

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

Return #

Returns a json.RawMessage containing the document.

NameTypeDescription
_idstringNewly created document ID
_versionintVersion of the document in the persistent data storage
_sourceobjectThe created document

Usage #

_, err := kuzzle.Document.Create(
  "nyc-open-data",
  "yellow-taxi",
  "some-id",
  json.RawMessage(`{"capacity": 4}`),
  nil)
response, err := kuzzle.Document.Get("nyc-open-data", "yellow-taxi", "some-id", nil)
if err != nil {
  log.Fatal(err)
} else {
  fmt.Println(string(response))
  /*
  {
    "_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
      }
    }
  }
  */
  fmt.Println("Success")
}