Skip to content

Get Document API

The Get API allows to get a document from the index based on its ID. The following example gets a document from an index called “twitter”, with ID valued 1:

GET /twitter/tweet/1

The result of the above get operation is a 200 OK HTTP response code with the following body:

{
"user": "Kronuz",
"post_date": "2019-03-22T14:35:26",
"message": "Trying out Xapiand",
"_id": 1,
"_version": 1
}

The above result includes the _id and _version of the document we wish to retrieve, additionally to the actual body of the document.

If the document is not found, it will return a 404 Not Found HTTP response code.

By passing the comments query param (or starting the node with --comments, which -vvvv implies), the result carries the engine’s bookkeeping too: #docid is the document’s number in the index and #shard the shard that holds it.

GET /twitter/tweet/1?comments=true

A selector keeps one part of the document. Pass it in the selector query param, or after the ID, as in GET /twitter/tweet/1.user:

GET /twitter/tweet/1?selector=user

read=linearizable (or volatile, which means it) waits until every write the node answered before the get has applied, an ack=none write included. The default, read=prefix, reads what has applied; see Visibility and Durability.

Sources: src/server/search_views.cc:1834-1889 (the get and the #docid, #shard fields, only with request.comments), src/opts.cc:252-255 (--comments), and query_field_maker in src/server/search_views.cc (volatile, read).