semantica.vector_store provides a unified API for storing and searching vector embeddings across all major backends:
  • Swap backends with a one-line change: no application code changes needed
  • HybridSearch fuses dense vector similarity with metadata filtering via RRF or weighted average
  • NamespaceManager for multi-tenant structural isolation
  • FAISSStore with flat, ivf, hnsw, and pq index types
  • Batch embed and store with parallel workers; metadata update without re-embedding

Exported Classes

What You Get

  • VectorStore — Unified interface across FAISS, Pinecone, Weaviate, Qdrant, Milvus, PgVector
    • One-line backend swap: no application code changes
    • add_documents() auto-embeds; store_vectors() for pre-computed embeddings
  • HybridSearch — Dense vector similarity with metadata filtering
    • RRF or weighted-average fusion strategies
    • Multi-source fusion across separate collections
  • MetadataStore — Rich metadata indexing by field values
    • Update metadata fields without re-embedding
    • OR and AND query operators
  • NamespaceManager — Structural per-tenant namespace isolation
    • Faster queries (smaller search space per tenant)
    • Safer than metadata-filter-only separation
  • Batch Operations — Bulk add, delete, and metadata updates
    • Parallel embedding with configurable batch_size and workers
    • In-place vector updates without full re-indexing
  • FAISS Index Types — flat, ivf, hnsw, and pq index types
    • Full configuration control via FAISSStore.create_index()
    • save() / load() for disk persistence

Getting Started

VectorStore is the main entry point. Use "inmemory" for development and "faiss" for local production:
Match vector dimension to your embedding model. The dimension parameter must exactly match your embedding model’s output size: BAAI/bge-small-en-v1.5 = 384, all-MiniLM-L6-v2 = 384, all-mpnet-base-v2 = 768, bge-large-en-v1.5 = 1024. A mismatch raises an error at insert time.
Use add_documents() for text, store_vectors() for pre-computed embeddings. add_documents() auto-embeds in parallel batches. If your embeddings are already computed (e.g. from a fine-tuned model), use store_vectors() directly to skip re-embedding.

Quick Start

1

Create a vector store

2

Add vectors

3

Search by semantic similarity

4

Filter results by metadata

Backends

No installation or API key required. FAISS requires pip install faiss-cpu.

Backend Selection Guide

HybridSearch

HybridSearch combines vector similarity with metadata filtering. Pass vector_store at construction to avoid supplying raw vectors on every call:
Without a vector_store, pass vectors explicitly:
Multi-source fusion across separate collections:
Use HybridSearch(vector_store=store) to avoid passing raw vectors on every call. When vector_store is set, search() pulls vectors and metadata from the store automatically: you only need to pass the query and filter.

Metadata Filtering

MetadataFilter supports chained conditions: all conditions are ANDed:

MetadataFilter Methods

SearchRanker

SearchRanker fuses results from multiple ranked lists:

Namespace Isolation

Use NamespaceManager to assign vectors to named namespaces for multi-tenant isolation:
Use NamespaceManager for multi-tenant applications. Storing all tenants’ vectors in the same collection and filtering by metadata at query time is slow and risks data leakage if a filter is accidentally omitted. Namespace isolation is both faster (smaller search space) and safer (structural isolation).

Batch Operations

Persistence (FAISS and in-memory)

Cloud backends (Pinecone, Weaviate, Qdrant, Milvus, PgVector) manage persistence themselves. save()/load() are for the in-memory and FAISS backends only.
inmemory and faiss backends lose data on process exit without save(). Call store.save(path) after adding vectors. Cloud backends (Pinecone, Qdrant, Weaviate, Milvus, PgVector) persist automatically.

MetadataStore

MetadataStore indexes structured metadata and lets you query by field values without a vector:
Update metadata without re-embedding. MetadataStore.update_metadata(id, {...}) changes attached fields (status, tags, review date) without re-running the embedding model. Use this for state changes that don’t affect semantic content.

FAISS Index Type Reference

FAISS index type is configured by creating a FAISSStore directly and calling create_index(). Use lowercase type names:
FAISS index type names are lowercase. The FAISSStore.create_index() method expects "flat", "ivf", "hnsw", "pq": not "Flat", "IVF", "HNSW", "PQ". Uppercase values raise ValidationError.
When using VectorStore(backend="faiss"), the underlying FAISSStore is initialised with a flat index by default. To use ivf/hnsw/pq, construct FAISSStore directly and call create_index() with the desired type.

Common Workflows

  • Embeddings — Generate the vectors stored here.
  • Context — AgentContext uses VectorStore for memory retrieval.
  • Split — Chunk documents before embedding and storing.
  • Ingest — Ingest documents before embedding and storing.