Reference
db.get
Return the metadata stored for an id.
db.get(id: str) -> str | NoneParameters
Section titled “Parameters”- id : str The vector’s id.
Returns
Section titled “Returns”str | None: the metadata as a JSON object string, including the id under the key "__id__" (parse it with json.loads), or None if no live vector has this id: it never existed or was deleted. Like dict.get, an unknown id is not an error.
Raises
Section titled “Raises”-
OSError Reading the metadata failed.
-
RuntimeError An internal fault occurred.
- Thread safety: releases the GIL and takes a shared lock, so calls from several threads run in parallel; they wait while a write is running. See Threads and processes.
Examples
Section titled “Examples”import jsonimport srvdb
db = srvdb.create("./vectors", dimension=128)v = [1.0] + [0.0] * 127 # tiny 128-dimension vectorsw = [0.0, 1.0] + [0.0] * 126db.add(["a"], [v], [json.dumps({"title": "A"})])print(json.loads(db.get("a")))# {'__id__': 'a', 'title': 'A'}print(db.get("missing"))# NoneSee also
Section titled “See also”db.get_all_ids: Return every live id.db.search: Find the k nearest vectors to a query.
Was this page helpful? Tell us in Discussions.