Metadata
Every entry in a store has two halves: a key (the
vector) and a value. That value is the entry's
metadata — a set of named fields describing it, stored in a StoreValue.
Where the vector captures meaning, metadata captures facts: who wrote it, what category it belongs to, when it was created, the original text or image. It's how you keep the human-readable context next to the vector.
Fields and values
Metadata is a map from field names to values:
Text
{ author: "Asimov", genre: "SciFi", tags: "epic, space" }
- Field name — a label you choose (
author,genre,category, …). - Value — the data for that field. Values can be text (
raw_string) or binary such as an image (raw_binary).
You decide the shape of your metadata; Ahnlich doesn't impose a fixed schema on the fields inside a value.
What metadata is for
Metadata earns its place in three ways:
- Context on results — search returns the vector and its metadata, so you get back the author, title, or original text — not just an opaque list of numbers.
- Filtering — select entries by their fields with
Get by predicate (e.g. every entry where
author = "Asimov"). A predicate is simply a condition over metadata; see the predicates reference for the full grammar. - Narrowing similarity search — pass a predicate as the
conditionon Similarity search to rank only the vectors that also match the metadata — "nearest neighbours wheregenre = SciFi".
Making metadata fast
Filtering scans metadata, which slows down on large stores. Tell Ahnlich which fields you filter on so it can index them:
- declare them as
create_predicateswhen you create the store, or - add a predicate index later.
An index turns a full scan into a direct lookup.