> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/avnlp/vectordb/llms.txt
> Use this file to discover all available pages before exploring further.

# Database wrappers

> Core vector database wrapper APIs for Chroma, Milvus, Pinecone, Qdrant, and Weaviate

Core database wrapper classes that provide unified interfaces to vector databases. These wrappers are used by both Haystack and LangChain integrations.

## ChromaVectorDB

Comprehensive Chroma Vector Database interface for Haystack integration with support for cloud deployments, local persistent storage, and ephemeral in-memory storage.

### Constructor

```python theme={null}
ChromaVectorDB(
    host: Optional[str] = None,
    port: Optional[int] = None,
    api_key: Optional[str] = None,
    tenant: Optional[str] = None,
    database: Optional[str] = None,
    path: Optional[str] = None,
    persistent: bool = True,
    collection_name: Optional[str] = None,
    config: Optional[Dict[str, Any]] = None,
    config_path: Optional[str] = None,
    **kwargs: Any
)
```

<ParamField path="host" type="str" optional>
  Chroma server hostname for HttpClient connections
</ParamField>

<ParamField path="port" type="int" optional>
  Chroma server port number (default: 8000)
</ParamField>

<ParamField path="api_key" type="str" optional>
  API key for authenticated Chroma instances
</ParamField>

<ParamField path="tenant" type="str" optional>
  Tenant name for multi-tenant mode (default: "default\_tenant")
</ParamField>

<ParamField path="database" type="str" optional>
  Database name within tenant (default: "default\_database")
</ParamField>

<ParamField path="path" type="str" optional>
  Local storage path for PersistentClient (default: "./chroma")
</ParamField>

<ParamField path="persistent" type="bool" default="True">
  Use persistent storage when no host provided
</ParamField>

<ParamField path="collection_name" type="str" optional>
  Default collection name for operations
</ParamField>

<ParamField path="config" type="Dict[str, Any]" optional>
  Direct configuration dictionary to load settings from
</ParamField>

<ParamField path="config_path" type="str" optional>
  Path to YAML configuration file
</ParamField>

<ParamField path="**kwargs" type="Any" optional>
  Additional parameters including ssl, tracing\_project\_name
</ParamField>

### Methods

#### create\_collection

Create a new collection in the Chroma database.

```python theme={null}
create_collection(
    name: str,
    configuration: Optional[CollectionConfiguration] = None,
    metadata: Optional[CollectionMetadata] = None,
    embedding_function: Optional[EmbeddingFunction[Embeddable]] = None,
    get_or_create: bool = True,
    **kwargs: Any
) -> None
```

<ParamField path="name" type="str" required>
  Unique identifier for the collection
</ParamField>

<ParamField path="configuration" type="CollectionConfiguration" optional>
  Collection-specific configuration object
</ParamField>

<ParamField path="metadata" type="CollectionMetadata" optional>
  Metadata to associate with the collection
</ParamField>

<ParamField path="embedding_function" type="EmbeddingFunction" optional>
  Function to generate embeddings. Uses DefaultEmbeddingFunction if not provided
</ParamField>

<ParamField path="get_or_create" type="bool" default="True">
  If True, retrieves existing collection if it exists. If False, raises error if collection exists
</ParamField>

#### upsert

Insert or update documents in the current collection.

```python theme={null}
upsert(
    data: Union[List[Any], Dict[str, Any]],
    **kwargs: Any
) -> None
```

<ParamField path="data" type="Union[List[Any], Dict[str, Any]]" required>
  Either a list of Haystack Documents or a dictionary with keys: ids, documents/texts, metadatas, embeddings
</ParamField>

#### query

Query the collection for similar vectors.

```python theme={null}
query(
    query_embedding: Optional[list[float]] = None,
    query_text: Optional[str] = None,
    n_results: int = 10,
    where: Optional[dict[str, Any]] = None,
    where_document: Optional[dict[str, Any]] = None,
    include: List[str] = None,
    include_vectors: bool = False,
    **kwargs: Any
) -> dict[str, Any]
```

<ParamField path="query_embedding" type="list[float]" optional>
  Vector embedding to search for
</ParamField>

<ParamField path="query_text" type="str" optional>
  Raw text to embed and search for
</ParamField>

<ParamField path="n_results" type="int" default="10">
  Maximum number of results to return
</ParamField>

<ParamField path="where" type="dict[str, Any]" optional>
  Metadata filter conditions (Chroma filter syntax)
</ParamField>

<ParamField path="where_document" type="dict[str, Any]" optional>
  Document content filter conditions
</ParamField>

<ParamField path="include" type="List[str]" optional>
  List of fields to include in results. Defaults to \["metadatas", "documents", "distances"]
</ParamField>

<ParamField path="include_vectors" type="bool" default="False">
  Whether to include embeddings in results
</ParamField>

<ResponseField name="ids" type="List[str]">
  List of document IDs
</ResponseField>

<ResponseField name="documents" type="List[str]">
  List of document contents
</ResponseField>

<ResponseField name="metadatas" type="List[dict]">
  List of metadata dictionaries
</ResponseField>

<ResponseField name="distances" type="List[float]">
  List of distance scores
</ResponseField>

<ResponseField name="embeddings" type="List[List[float]]" optional>
  List of vectors (if include\_vectors=True)
</ResponseField>

#### delete\_collection

Delete a collection from the Chroma database.

```python theme={null}
delete_collection(name: Optional[str] = None) -> None
```

<ParamField path="name" type="str" optional>
  Name of collection to delete. Uses default collection\_name if not provided
</ParamField>

#### flatten\_metadata

Recursively flatten nested metadata for Chroma compatibility.

```python theme={null}
flatten_metadata(metadata: Dict[str, Any]) -> Dict[str, Any]
```

<ParamField path="metadata" type="Dict[str, Any]" required>
  Dictionary potentially containing nested dictionaries, lists, or complex types
</ParamField>

<ResponseField name="flattened" type="Dict[str, Any]">
  Flattened dictionary compatible with Chroma metadata storage. Nested keys use dot notation (e.g., "parent.child.key")
</ResponseField>

***

## MilvusVectorDB

Interface for interacting with Milvus/Zilliz vector databases with support for dense vectors, sparse vectors, and hybrid search.

### Constructor

```python theme={null}
MilvusVectorDB(
    uri: str = "http://localhost:19530",
    token: str = "",
    host: Optional[str] = None,
    port: Optional[str] = None,
    collection_name: Optional[str] = None,
    **kwargs
)
```

<ParamField path="uri" type="str" default="http://localhost:19530">
  Milvus server URI. Use "[http://localhost:19530](http://localhost:19530)" for local Milvus or "https\://..." for Zilliz Cloud endpoints
</ParamField>

<ParamField path="token" type="str" default="">
  API token for Zilliz Cloud authentication. Leave empty for local Milvus or when using no authentication
</ParamField>

<ParamField path="host" type="str" optional>
  Deprecated. Use uri instead. Maintained for backward compatibility
</ParamField>

<ParamField path="port" type="str" optional>
  Deprecated. Use uri instead. Maintained for backward compatibility
</ParamField>

<ParamField path="collection_name" type="str" optional>
  Default collection name for operations. Can be overridden per-method
</ParamField>

### Methods

#### create\_collection

Create a Milvus collection with comprehensive schema for document storage.

```python theme={null}
create_collection(
    collection_name: str,
    dimension: int,
    description: str = "",
    use_sparse: bool = False,
    use_partition_key: bool = False,
    partition_key_field: str = "namespace",
    recreate: bool = False
)
```

<ParamField path="collection_name" type="str" required>
  Unique name for the collection
</ParamField>

<ParamField path="dimension" type="int" required>
  Dimensionality of dense embedding vectors. Must match the embedding model used (e.g., 768 for most transformer models)
</ParamField>

<ParamField path="description" type="str" default="">
  Human-readable description of the collection's purpose
</ParamField>

<ParamField path="use_sparse" type="bool" default="False">
  Whether to include a sparse vector field for hybrid search. Adds storage overhead but enables keyword matching alongside semantic search
</ParamField>

<ParamField path="use_partition_key" type="bool" default="False">
  Whether to enable physical data partitioning. Enables efficient multi-tenancy by isolating data at the partition level
</ParamField>

<ParamField path="partition_key_field" type="str" default="namespace">
  Name of the partition key field. Documents with the same partition key value are routed to the same physical partition
</ParamField>

<ParamField path="recreate" type="bool" default="False">
  If True, drops existing collection with the same name before creating new one. Use with caution in production
</ParamField>

#### search

Perform semantic search with support for dense, sparse, or hybrid retrieval.

```python theme={null}
search(
    query_embedding: Optional[List[float]] = None,
    query_sparse_embedding: Optional[Union[Dict[int, float], SparseEmbedding]] = None,
    top_k: int = 10,
    collection_name: Optional[str] = None,
    filters: Optional[Dict[str, Any]] = None,
    scope: Optional[str] = None,
    namespace: Optional[str] = None,
    partition_key_field: str = "namespace",
    ranker_type: str = "rrf",
    weights: Optional[List[float]] = None,
    include_vectors: bool = False
) -> List[Document]
```

<ParamField path="query_embedding" type="List[float]" optional>
  Dense query vector for semantic search. Typically from a text embedding model (e.g., 768-dim)
</ParamField>

<ParamField path="query_sparse_embedding" type="Union[Dict[int, float], SparseEmbedding]" optional>
  Sparse query vector for keyword search. Can be Dict\[int, float] mapping term IDs to weights, or Haystack SparseEmbedding
</ParamField>

<ParamField path="top_k" type="int" default="10">
  Maximum number of results to return
</ParamField>

<ParamField path="collection_name" type="str" optional>
  Target collection. Uses default from constructor if None
</ParamField>

<ParamField path="filters" type="Dict[str, Any]" optional>
  Metadata filter conditions as nested dict. Supports operators: $eq (equality), $gt/$lt (range), $in (list membership), \$contains (JSON contains)
</ParamField>

<ParamField path="scope" type="str" optional>
  Unified tenant/partition identifier. Preferred over 'namespace' as it clearly conveys the isolation concept
</ParamField>

<ParamField path="namespace" type="str" optional>
  Legacy alias for scope. Partition key value for data isolation. Only used if scope is not provided
</ParamField>

<ParamField path="partition_key_field" type="str" default="namespace">
  Name of the partition key field in schema. Used to construct partition filter expressions
</ParamField>

<ParamField path="ranker_type" type="str" default="rrf">
  Reranking strategy for hybrid search. "rrf" uses Reciprocal Rank Fusion (k=60 constant). "weighted" uses explicit weights
</ParamField>

<ParamField path="weights" type="List[float]" optional>
  Two-element list \[dense\_weight, sparse\_weight] for weighted ranker. Only used when ranker\_type="weighted". Defaults to \[0.5, 0.5]
</ParamField>

<ParamField path="include_vectors" type="bool" default="False">
  If True, includes embedding vectors in returned Documents. Increases response size but useful for downstream processing
</ParamField>

<ResponseField name="documents" type="List[Document]">
  List of Haystack Document objects ordered by relevance score (descending). Documents include content, metadata, score, and optionally embeddings
</ResponseField>

***

## PineconeVectorDB

Production-ready interface for Pinecone vector database operations with support for hybrid search and multi-tenancy.

### Constructor

```python theme={null}
PineconeVectorDB(
    api_key: Optional[str] = None,
    index_name: Optional[str] = None,
    config: Optional[Dict[str, Any]] = None,
    config_path: Optional[str] = None,
    **kwargs
)
```

<ParamField path="api_key" type="str" optional>
  Pinecone API key for authentication
</ParamField>

<ParamField path="index_name" type="str" optional>
  Name of the Pinecone index to operate on
</ParamField>

<ParamField path="config" type="Dict[str, Any]" optional>
  Direct configuration dictionary
</ParamField>

<ParamField path="config_path" type="str" optional>
  Path to YAML configuration file
</ParamField>

<ParamField path="**kwargs" type="Any" optional>
  Additional connection parameters (host, proxy\_url, ssl\_verify, pool\_threads)
</ParamField>

### Methods

#### create\_index

Create a new Pinecone index or ensure an existing one is ready.

```python theme={null}
create_index(
    dimension: Optional[int] = None,
    metric: str = "cosine",
    spec: Optional[Union[Dict[str, Any], ServerlessSpec]] = None,
    recreate: bool = False,
    index_name: Optional[str] = None,
    **kwargs
) -> None
```

<ParamField path="dimension" type="int" required>
  Dimensionality of the vectors. Required for new indexes
</ParamField>

<ParamField path="metric" type="str" default="cosine">
  Distance metric for similarity calculations. Options: "cosine", "euclidean", "dotproduct"
</ParamField>

<ParamField path="spec" type="Union[Dict[str, Any], ServerlessSpec]" optional>
  ServerlessSpec or dict defining cloud provider and region. Defaults to AWS us-east-1 serverless if not provided
</ParamField>

<ParamField path="recreate" type="bool" default="False">
  If True, delete existing index before creating new one
</ParamField>

<ParamField path="index_name" type="str" optional>
  Override the index name from **init** for this operation
</ParamField>

#### query

Query the index for similar vectors.

```python theme={null}
query(
    vector: List[float],
    top_k: int = 10,
    filter: Optional[Dict[str, Any]] = None,
    namespace: str = "",
    scope: Optional[str] = None,
    include_metadata: bool = True,
    include_values: bool = False,
    include_vectors: bool = False
) -> List[Any]
```

<ParamField path="vector" type="List[float]" required>
  Query dense embedding vector
</ParamField>

<ParamField path="top_k" type="int" default="10">
  Number of results to return
</ParamField>

<ParamField path="filter" type="Dict[str, Any]" optional>
  Metadata filters to apply
</ParamField>

<ParamField path="namespace" type="str" default="">
  Namespace to search in (legacy parameter)
</ParamField>

<ParamField path="scope" type="str" optional>
  Unified scope/namespace parameter (preferred over namespace)
</ParamField>

<ParamField path="include_metadata" type="bool" default="True">
  Whether to include metadata in results
</ParamField>

<ParamField path="include_values" type="bool" default="False">
  Whether to include vector values in results (legacy parameter)
</ParamField>

<ParamField path="include_vectors" type="bool" default="False">
  Whether to include vector values in results (preferred parameter)
</ParamField>

<ResponseField name="results" type="List[Document]">
  List of Haystack Documents with content, metadata, and optional embeddings
</ResponseField>

#### flatten\_metadata

Transform nested metadata into Pinecone-compatible flat structure.

```python theme={null}
flatten_metadata(metadata: Dict[str, Any]) -> Dict[str, Any]
```

<ParamField path="metadata" type="Dict[str, Any]" required>
  Potentially nested dictionary with arbitrary values
</ParamField>

<ResponseField name="flattened" type="Dict[str, Any]">
  Flat dictionary with only Pinecone-supported types. Nested dictionaries use underscore notation (e.g., user.id becomes user\_id)
</ResponseField>
