from pathlib import Path from haystack import Document from haystack_integrations.components.retrievers.qdrant import QdrantEmbeddingRetriever from haystack_integrations.document_stores.qdrant import QdrantDocumentStore document_store = QdrantDocumentStore( path="support-qdrant-demo", index="support_articles", embedding_dim=3, similarity="cosine", recreate_index=True, return_embedding=True, progress_bar=False, ) documents = [ Document( content="Reset passwords through the identity portal.", meta={"topic": "accounts"}, embedding=[0.99, 0.03, 0.01], ), Document( content="Restart the search service after changing the index.", meta={"topic": "operations"}, embedding=[0.02, 0.98, 0.02], ), Document( content="Archive old invoices from the billing dashboard.", meta={"topic": "billing"}, embedding=[0.01, 0.02, 0.99], ), ] written = document_store.write_documents(documents) retriever = QdrantEmbeddingRetriever( document_store=document_store, top_k=1, return_embedding=True, ) match = retriever.run(query_embedding=[1.0, 0.0, 0.0])["documents"][0] print(f"documents written: {written}") print(f"documents stored: {document_store.count_documents()}") print(f"top match: {match.content}") print(f"match topic: {match.meta['topic']}") print(f"embedding returned: {match.embedding is not None}") print(f"qdrant path exists: {Path('support-qdrant-demo').is_dir()}")