Fetch a document #
Retrieve an existing document by specifying its unique identifier.
Examples #
Fetch a document from the my-collection collection with customized uuid news_001:
GET /my-collection/_doc/news_001
The API returns the following result:
{
"_collection": "default:my-collection",
"_id": "0,0",
"_key" : "news_001",
"found": true,
"source" : {
"message": "GET /search HTTP/1.1 200 1070000",
"org": {
"id": "infini"
}
}
}
As you can see, the customized uuid are represented as _key within the document,
and there is also a _id returned with value 0,0,
this is the internal id generated by Pizza, and it is guaranteed to be unique,
so you can also fetch this document by this value like this:
GET /my-collection/_doc/0,0
Request #
GET /<target>/_doc/<doc_id>
Path parameters #
<target>
(Required, string) Name of the collection to target.<doc_id>
(Required, string) The unique identify of this document, support both_keyor_id.
Query parameters #
key_as_id
(Optional, boolean) compatibility rendering: a keyed document answers with the user key AS_id(and the now-redundant_keyfolded away). The default keeps the system_idand reports the key as_key. Defaults tofalse.routing
(Required for a key-addressed fetch on a routed collection) — the routing VALUE (?routing=org-a) that places the document. A bare key has no home partition there and answers400; a value pointing at the wrong partition is an honest404. On collections without a routing field the parameter addresses nothing and is a400.
You can also use the HEAD method to simply find if the specified document
exists or not.
HEAD /<target>/_doc/<doc_id>