HybridDocumentStore<T>

Models & Types · AiDotNet.RetrievalAugmentedGeneration.DocumentStores

Hybrid document store combining vector and keyword search strategies.

Inheritance: DocumentStoreBase<T> → HybridDocumentStore<T>

For Beginners

Hybrid search is like having two search engines working together.

Think of it like asking two librarians:

  • Vector librarian: Finds books by meaning (semantic similarity)
  • Keyword librarian: Finds books by exact words (traditional search)
  • Results are combined for better accuracy

Why hybrid is better:

  • Vector search: Finds “climate change” when you search “global warming”
  • Keyword search: Finds exact product codes, names, IDs
  • Together: Best of both worlds!

Good for:

  • E-commerce product search
  • Document retrieval systems
  • Q&A systems
  • Any application needing both exact and semantic matches

How It Works

This implementation combines two separate document stores to enable hybrid search - one for vector similarity and one for keyword matching (like BM25). Results from both stores are weighted and combined for improved retrieval quality. This approach often outperforms pure vector or pure keyword search alone.

Constructors

Constructor Summary
HybridDocumentStore(IDocumentStore<T> vectorStore, IDocumentStore<T> keywordStore, T vectorWeight, T keywordWeight) Initializes a new instance of the HybridDocumentStore class.

Properties

Property Summary
int DocumentCount { get; } Gets the number of documents currently stored (from the vector store).
int VectorDimension { get; } Gets the dimensionality of vectors stored (from the vector store).

Methods

Method Summary
void Clear() Removes all documents from both underlying stores.