Skip to main content

DBConfig

The DBConfig class specifies the storage location for the index, with options for in-memory storage or databases.

Parameters

The supported location options are:
  • "rocksdb": Use for persistent, on-disk key-value storage (recommended for embedded/local deployments).
  • "s3": Use for AWS S3 or any S3-compatible object store (MinIO, Cloudflare R2). Connection string carries the URI and credentials.
  • "memory": Use for temporary in-memory storage (for benchmarking and evaluation purposes).
  • "threadsafememory": Use for thread-safe in-memory storage (for multi-threaded benchmarking).

Example Usage


Embeddings

The Embedded LangChain integration accepts any LangChain Embeddings implementation:

Supported Embedding Types

Example Usage


DistanceMetric

DistanceMetric is a string representing the distance metric used for the index. Options include:
  • "cosine": Cosine similarity (recommended for normalized embeddings)
  • "euclidean": Euclidean distance
  • "squared_euclidean": Squared Euclidean distance

Metric Characteristics


IndexType

The index type determines the algorithm used for approximate nearest neighbor search.

Available Index Types

The default index type for the Embedded library is "ivfsq".

Example Usage


IndexConfigParams

Optional parameters for configuring the index, passed as a dictionary.

Parameters by Index Type

IVFFlat

IVFPQ

IVFSQ

Tuning Guidelines

  • n_lists: Use √n where n is the expected number of vectors. Common values: 256, 512, 1024, 2048
  • pq_dim: Should divide the embedding dimension evenly. Lower values = more compression
  • pq_bits / sq_bits: 8 bits provides good balance. Lower = more compression, higher = better accuracy

Document

LangChain Document object used for storing text with metadata.

Attributes

Example Usage


Filter Format

Metadata filters use a dictionary format for querying documents.

Simple Filters

Advanced Filters

Supported Operators


Return Types

Query Results

Query operations return documents with optional scores:

Score Normalization

Scores are normalized to [0, 1] range where:
  • 1.0 = Perfect match
  • 0.0 = Worst match
The normalization depends on the distance metric used.

Async Support

All methods have async variants prefixed with a:

Example Usage