DocumentationAPI ReferenceπŸ““ TutorialsπŸ§‘β€πŸ³ Cookbook🀝 IntegrationsπŸ’œ Discord

QdrantDocumentStore

Use the Qdrant vector database with Haystack.

Qdrant is a powerful high-performance, massive-scale vector database. The QdrantDocumentStore can be used with any Qdrant instance, in-memory, locally persisted, hosted, and the official Qdrant Cloud.

Installation

You can simply install the Qdrant Haystack integration with:

pip install qdrant-haystack

Initialization

The quickest way to use QdrantDocumentStore is to create an in-memory instance of it:

from haystack.dataclasses.document import Document
from haystack_integrations.document_stores.qdrant import QdrantDocumentStore

document_store = QdrantDocumentStore(
    ":memory:",
    recreate_index=True,
    return_embedding=True,
    wait_result_from_api=True,
)
document_store.write_documents([
	  Document(content="This is first", embedding=[0.0]*5), 
	  Document(content="This is second", , embedding=[0.1, 0.2, 0.3, 0.4, 0.5])
])
print(document_store.count_documents())

You can also connect directly to Qdrant Cloud directly. Once you have your API key and your cluster URL from the Qdrant dashboard, you can connect like this:

from haystack.dataclasses.document import Document
from haystack_integrations.document_stores.qdrant import QdrantDocumentStore

document_store = QdrantDocumentStore(
		url="https://xxxxxx-xxxxx-xxxxx-xxxx-xxxxxxxxx.us-east.aws.cloud.qdrant.io:6333",
    api_key="<your-api-key>",
)
document_store.write_documents([
	  Document(content="This is first", embedding=[0.0]*5), 
	  Document(content="This is second", , embedding=[0.1, 0.2, 0.3, 0.4, 0.5])
])
print(document_store.count_documents())

Supported Retrievers

QdrantRetriever: Retrieves documents from the QdrantRetriever based on their dense embeddings (vectors).