Skip to main content

DBConfig

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

Parameters

The supported location options are:
  • "redis": Use for high-speed, in-memory storage (recommended for index_location)
  • "postgres": Use for reliable, SQL-based storage (recommended for config_location)
  • "memory": Use for temporary in-memory storage (for benchmarking and evaluation purposes)
  • "s3": Use for Amazon S3 or S3-compatible storage
  • "gcs": Use for Google Cloud Storage
  • "local": Use for local file system storage

Example Usage


Embeddings

The LangChain integration supports multiple embedding model types:

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

Example Usage


IndexConfigParams

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

Parameters by Index Type

IVFFlat & IVF

IVFPQ

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: 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