Skip to main content

Get by key

Retrieve entries by an exact vector-key match.

Every operation works on both Vector DB stores (you supply raw vectors) and AI stores (you supply text or images and Ahnlich AI generates the embeddings for you). Use the Vector DB / AI switch in the sample below.

Parameters

ParameterTypeDescription
storestringName of the store to read from.
keyslist of vectorsThe exact vector keys to look up.
schemastring · optionalSchema to target. Defaults to public.

All requests accept an optional schema field. When omitted, the server uses the public schema.

Behavior

  • Matches the stored entry whose key vector is exactly equal to the one supplied.
  • Returns nothing for keys that aren't present — it does not do nearest-neighbour matching (use Similarity search for that).

Sample query

Python
import asyncio
from grpclib.client import Channel
from ahnlich_client_py.grpc import keyval
from ahnlich_client_py.grpc.services.db_service import DbServiceStub
from ahnlich_client_py.grpc.db import query as db_query
from ahnlich_client_py.grpc.db.server import Get

async def get_key():
async with Channel(host="127.0.0.1", port=1369) as channel:
client = DbServiceStub(channel)

lookup_key = keyval.StoreKey(key=[1.0, 2.0, 3.0, 4.0]) # Your lookup vector

response = await client.get_key(
db_query.GetKey(
store="my_store",
schema="analytics",
keys=[lookup_key]
)
)
# response.entries contains matching (key, value) pairs
if __name__ == "__main__":
asyncio.run(get_key())

Response

The matching entries (vector + metadata). Empty if no key matches.