SKEG · CONCEPTS

How Skeg stores and searches data

Follow an article from application writes to search results and retrieved content.

Skeg 0.8 · Development documentation

You are building a help centre. Your application needs to save articles, find those related to a question, and return enough information to display the answer. This page follows one article through Skeg so you can see which part does what.

Your application turns text into coordinates

An embedding model converts an article into a vector: an ordered list of numbers. Your application sends that vector to Skeg with a numeric row ID. When someone asks a question, it uses the same embedding model to create the query vector.

Skeg receives the coordinates. It does not choose the embedding model or infer an embedding from a title. Different models can produce different dimensions and meanings; the stored vectors and queries need to belong to the same space.

Records hold the content; vector indexes make it searchable

For an article with ID 42, your application might store:

DataWhere the application puts itPurpose
Title or textA key such as article:42:textRetrieve the content to display
EmbeddingRow 42 of a vector indexFind similar articles
lang=it year=2025The row’s payloadRestrict eligible results or return metadata

These are separate writes. The application chooses how to name its keys and associate the content with a row ID. Skeg does not create article:42:text automatically when a vector is written.

A vector index also has a dimension. An index with 768 coordinates per row cannot accept a query with 384 coordinates. Create a separate index when the representation changes rather than mixing incompatible vectors.

A disk index finds a shortlist, then scores it more precisely

Comparing a question with every article can become expensive as the archive grows. Skeg’s disk backend uses a graph called Vamana to navigate between vectors and find promising rows without scoring the entire archive.

For that navigation it uses a compact representation of the vectors. Quantization is the reduction from full-precision coordinates to a smaller representation. It reduces the memory needed for this part of the search, while giving up some precision.

The search produces a shortlist of candidate IDs. Skeg then reads their full-precision vectors from disk and calculates more precise scores. This second step is reranking: the candidate list is reordered before the highest-scoring rows are returned.

StepWhat it produces
Navigate the graphCandidate rows worth examining
Read and score full-precision vectorsMore precise scores for those candidates
Select the requested resultsRow IDs, scores and optional payloads
Application fetches contentArticle text or other information to display

Reranking can fix the order of the shortlist. It cannot add an article that never reached the shortlist. This is the practical reason search effort matters: a faster search can do less work but miss a useful neighbour. The worked example shows that failure with three rows.

Flat and disk indexes serve different needs

The flat backend keeps its search structure in memory. In the current API, flat indexes are explicitly temporary: create them with PERSISTENCE ephemeral. They do not survive a restart as durable indexes.

The disk backend stores its index in files and uses caches for frequently accessed data. It is the durable option. Disk storage reduces the need to keep the full vectors resident, but it does not make the server’s RAM usage zero: compact representations, key indexes, caches and work in progress still use memory.

See the creation reference for accepted backend and persistence combinations. Use operations to plan the process’s memory use.

A filter decides which articles are eligible

A question about account access may be relevant to English and Italian articles. If the caller needs Italian results, attach a language field to the payload and search with FILTER "lang = it".

That requirement changes the search target: the nearest eligible articles. Depending on how many rows match and which search structures are available, Skeg can scan matching rows or search a routed shortlist. EXPLAIN reports the plan used for a particular query.

Follow payloads and filters for a complete example. A language or owner filter is an application condition; use authenticated tenant boundaries when data access needs to be isolated between users.

Shards divide the work inside the process

Skeg divides storage and work among shards. Each shard has a worker and its own storage. A query may ask several shards for results, then merge their answers. These shards are parts of one server, not replicas on separate machines.

During movement between shards, a row can temporarily have more than one copy. Row versions let reads distinguish a newer value from an older copy; moving bytes does not make an old value new again.

Skeg is a single-node system. It does not provide distributed replication or automatic failover. See deployment for storage, backup and network requirements.