Use the get() method to retrieve documents by their _id.
get() provides direct key-based lookup, similar to a key-value store.
This operation is optimized for high throughput and low latency.
docs = client.collection("books").get(["lotr", "moby"])
The result is a key-value mapping: each key is a document ID and each value is a full document as it was upserted into the collection.
# Example response
{
"lotr": {
"_id": "lotr",
"title": "The Lord of the Rings",
"author": "J.R.R. Tolkien",
"published_year": 1954
},
"moby": {
"_id": "moby",
"title": "Moby Dick",
"author": "Herman Melville",
"published_year": 1851
}
}
If a document with a given ID does not exist in the collection, it is simply
omitted from the results - no error is thrown.