Skip to content
ParticleDB
Release candidateParticleDB 1.1.19-rc.17 is not yet GA or ready for production data.Release status →

Search and memory

An embedding is a numeric vector produced by an embedding model. Generate stored embeddings and query embeddings with the same model and dimensions.

The small vectors below illustrate query behavior. They are not outputs from an embedding model.

Store records with their vectors and return the nearest ones. Each client sends the distance query through its query call.

Uses db from the connect example.

db.execute("CREATE TABLE memories (id BIGINT PRIMARY KEY, note TEXT, embedding VECTOR(3))")
db.execute("INSERT INTO memories VALUES (1, 'refund policy', '[1,0,0]'), "
           "(2, 'shipping times', '[0,1,0]'), (3, 'return window', '[0.9,0.1,0]')")
print(db.query("SELECT id, note FROM memories ORDER BY embedding <-> $1 LIMIT 2", ["[1,0,0]"]))
Output
[{'id': 1, 'note': 'refund policy'}, {'id': 3, 'note': 'return window'}]
CREATE TABLE knowledge (
id BIGINT PRIMARY KEY,
account_id BIGINT,
content TEXT,
embedding VECTOR(3)
);
INSERT INTO knowledge VALUES
(1, 7, 'Deployment guide', '[1,0,0]'),
(2, 7, 'API reference', '[0,1,0]'),
(3, 9, 'Private account note', '[1,0,0]');
SELECT id, content
FROM knowledge
WHERE account_id = 7
ORDER BY embedding <-> '[1,0,0]'
LIMIT 2;

The deployment guide ranks first. Record 3 is excluded by the account filter.

A filter is part of your query, not a complete authorization system. Derive the account scope from authenticated application identity and enforce it on every access path. Security.

Choose a supported index and distance metric using the vector reference. Measure retrieval quality and latency on representative embeddings before choosing index parameters.

Vector search reference · Full-text search · Agent patterns