The Vector Store holds embedding vectors in named collections and supports similarity search. Use it for RAG context, agent memory, and any workflow that involves finding similar items.

Command Overview

CommandSyntaxReturns
vector createvector create <name> <dim> [--metric M]OK
vector dropvector drop <name>OK
vector collectionsvector collectionsAll collections
vector statsvector stats <coll>Collection details
vector upsertvector upsert <coll> <key> <vector> [--metadata JSON]OK
vector batch-upsertvector batch-upsert <coll> <json>OK
vector getvector get <coll> <key>Vector data
vector delvector del <coll> <key>OK
vector searchvector search <coll> <query> [k] [--metric M] [--filter JSON]Top-k matches

Collections

Before storing vectors, create a collection with a fixed dimension and distance metric:

$ strata --cache
strata:default/default> vector create embeddings 384 --metric cosine
OK
strata:default/default> vector create positions 3 --metric euclidean
OK
strata:default/default> vector create scores 128 --metric dot
OK

Distance Metrics

MetricBest ForScore Range
cosineText embeddings, normalized vectors[-1, 1] (higher = more similar)
euclideanSpatial data, positions(0, 1] (higher = more similar)
dotPre-normalized embeddings, scoringUnbounded (higher = more similar)

All metrics are normalized so that higher scores = more similar.

List Collections

$ strata --cache
strata:default/default> vector create embeddings 384 --metric cosine
OK
strata:default/default> vector collections
embeddings: 384 dimensions, cosine metric, 0 vectors

Collection Statistics

Get detailed information about a specific collection:

$ strata --cache
strata:default/default> vector create embeddings 384 --metric cosine
OK
strata:default/default> vector stats embeddings
name: embeddings
count: 0
dimension: 384
metric: cosine
index_type: flat
memory_bytes: 0

Delete a Collection

$ strata --cache
strata:default/default> vector create old-collection 4 --metric cosine
OK
strata:default/default> vector drop old-collection
OK

Index Backends

The Vector Store supports two index backends:

BackendComplexityRecallBest For
Brute ForceO(n) exact100%Collections < 10K vectors
HNSWO(log n) approximate~95%+Collections 10K+ vectors

The default backend is Brute Force. HNSW can be selected per collection at creation time via the engine-level configuration.

HNSW Configuration

The HNSW backend accepts the following parameters:

ParameterDefaultDescription
m16Max connections per graph layer
ef_construction200Beam width during index build (higher = better recall, slower build)
ef_search50Beam width during search (higher = better recall, slower search)
ml1/ln(m)Level multiplier for probabilistic layer assignment

Storing Vectors

Use vector upsert to insert or update a vector by key:

$ strata --cache
strata:default/default> vector create docs 4 --metric cosine
OK
strata:default/default> vector upsert docs doc-1 [1.0,0.0,0.0,0.0]
OK
strata:default/default> vector upsert docs doc-2 [0.0,1.0,0.0,0.0] --metadata '{"source":"conversation","timestamp":1234567890}'
OK

The dimension of the vector must match the collection’s dimension. A mismatch returns a DimensionMismatch error.

Batch Upsert

For bulk loading, use vector batch-upsert to insert multiple vectors in a single operation:

strata --cache vector batch-upsert docs '[{"key":"chunk-0","vector":[1.0,0.0,0.0,0.0],"metadata":{"page":1}},{"key":"chunk-1","vector":[0.0,1.0,0.0,0.0],"metadata":{"page":2}},{"key":"chunk-2","vector":[0.0,0.0,1.0,0.0],"metadata":{"page":3}}]'

Batch upsert validates all entries before committing. If any entry has an invalid dimension, the entire batch fails atomically (no partial writes).

Retrieving Vectors

$ strata --cache
strata:default/default> vector create docs 4 --metric cosine
OK
strata:default/default> vector upsert docs doc-1 [1.0,0.0,0.0,0.0]
OK
strata:default/default> vector get docs doc-1
key=doc-1 vector=[1.0,0.0,0.0,0.0] metadata=null

Searching

Search for the k most similar vectors to a query:

$ strata --cache
strata:default/default> vector create items 4 --metric cosine
OK
strata:default/default> vector upsert items a [1.0,0.0,0.0,0.0]
OK
strata:default/default> vector upsert items b [0.9,0.1,0.0,0.0]
OK
strata:default/default> vector upsert items c [0.0,1.0,0.0,0.0]
OK
strata:default/default> vector search items [1.0,0.0,0.0,0.0] 2
key=a score=1.0000
key=b score=0.9939

Search Result Fields

FieldDescription
keyThe vector’s key
scoreSimilarity score (higher = more similar)
metadataThe vector’s metadata (if stored)

Metadata Filtering

Search results can be filtered by metadata using 8 operators:

OperatorDescriptionExample
eqEqualssource == "docs"
neNot equalsstatus != "archived"
gtGreater thanscore > 0.5
gteGreater than or equalversion >= 2
ltLess thanpriority < 10
lteLess than or equalage <= 30
inValue in setcategory in ["a", "b"]
containsString contains substringname contains "test"
strata --cache vector search items [1.0,0.0,0.0,0.0] 10 --filter '{"source":{"eq":"docs"}}'

Metadata filtering is post-filter — the backend returns candidates, then metadata is loaded and filtered. The engine uses adaptive over-fetch (3x, 6x, 12x multipliers) to ensure enough results survive filtering.

Deleting Vectors

$ strata --cache
strata:default/default> vector create docs 4 --metric cosine
OK
strata:default/default> vector upsert docs doc-1 [1.0,0.0,0.0,0.0]
OK
strata:default/default> vector del docs doc-1
OK

Common Patterns

RAG Context Store

#!/bin/bash
set -euo pipefail

# Create collection
strata --cache vector create knowledge 384 --metric cosine

# Bulk-index document chunks (generate embeddings externally)
strata --cache vector batch-upsert knowledge '[
  {"key":"chunk-0","vector":[...],"metadata":{"text":"...","source":"docs","chunk_index":0}},
  {"key":"chunk-1","vector":[...],"metadata":{"text":"...","source":"docs","chunk_index":1}}
]'

# Search for relevant context
strata --cache vector search knowledge "[0.1,0.2,...]" 5

Branch Isolation

Vector collections and their data are isolated by branch.

Space Isolation

Within a branch, vector collections are scoped to the current space. Each space has its own independent set of collections:

$ strata --cache
strata:default/default> vector create docs 4 --metric cosine
OK
strata:default/default> vector upsert docs item-1 [1.0,0.0,0.0,0.0]
OK
strata:default/default> use default other
strata:default/other> vector collections
(empty)

See Spaces for the full guide.

Transactions

Vector operations do not participate in transactions. They are executed immediately and are always visible, even within a session that has an active transaction.

Next