What you’ll add
- A new module under
crates/cognis-rag/src/vectorstore/<name>.rs(or a directory for larger backends). - A struct implementing
VectorStore, plus a<Name>Builderfor hosted backends. - A feature flag in
crates/cognis-rag/Cargo.toml(vectorstore-<name>). - Tests with mocked HTTP if hosted, or in-process if local.
- An example under
examples/retrieval/. - Documentation entries in Embeddings and vector stores and Feature flags.
The trait
SearchResult is { id, text, score, metadata }. add_texts returns the IDs the store assigned; add_vectors is the lower-level entry when the caller has already paid the embedding cost.
For backends that don’t natively support a method, provide a sensible fallback (similarity_search_with_filter has one already) and document the difference.
Step 1 — Build the struct
For a hosted backend:Step 2 — Feature flag
crates/cognis-rag/src/lib.rs:
cognis umbrella does not auto-glob from cognis_rag — it explicitly lists the types it re-exports at the top level. Add your types to the relevant pub use cognis_rag::{...} block in crates/cognis/src/lib.rs so users get cognis::MyVectorStore without an extra import. Existing entries there (e.g. InMemoryVectorStore, Filter) are the template.
Step 3 — Tests
Mocked HTTP for hosted; in-process tests for local.add_textsfollowed bysimilarity_searchreturns the right docs.deleteactually removes — a search after delete shouldn’t find the deleted ids.similarity_search_with_filtereither filters or falls back gracefully (and the doc page says which).- Error paths — what happens when the service is down, returns 5xx, or the collection doesn’t exist.
Step 4 — Add an example
crates/examples/Cargo.toml with a name like retrieval_myvector_basics.
Step 5 — Update docs
/building-rag/embeddings— add a row in the vector-store table and a tab in the picker./reference/feature-flags— add the feature row./reference/api/cognis-rag— add the type to the inventory.
Step 6 — PR
Title:feat(rag): add MyVectorStore. Description should mention:
- The backend’s public docs.
- Feature flag name.
- Whether
similarity_search_with_filteris native or an in-process fallback. - Anything not yet supported.
See also
Adding a provider
Same shape, different domain.
cognis-rag reference
Trait surface and existing implementations.