Index and adding documents to qdrant cloud

vectorstore = QdrantVectorStore.from_documents(
    [],
    url=os.getenv("QDRANT_ENDPOINT"),
    api_key=os.getenv("QDRANT_API_KEY"),
    prefer_grpc=True,
    collection_name=COLLECTION_NAME,
    embedding=embedding,
    content_payload_key="page_content",
    metadata_payload_key="metadata", 
    )

# document 
doc = Document(page_content="For fever and pain relief", metadata={
  "question": "What are the usage of paracetamol",
  "source": "QnA",
  "category": "QnA",
  "last_modified": "2025-07-27T17:18:00.115384+00:00",
  "doc_id": "QA-1130"
} )

vectorstore.add_documents([doc])

test_docs = vectorstore.similarity_search(
                "test", 
                k=1, 
                filter=models.Filter(
                    must=[
                        models.FieldCondition(
                            key="metadata.source",
                            match=models.MatchText(text="QnA")
                        )
                    ]
                )
            )

I am a beginner in langchain and qdrant and II’m attempting to create an index for metadata in my Qdrant Cloud collection so I can do filtered searches, but I keep running into the same frustrating issue - my test_docsresults always come back empty, no matter what I try.

So far, I’ve experimented with:

  • Using QdrantVectorStore directly
  • Trying QdrantVectorStore.from_documents()
  • Testing both with and without the metadata_payload_key parameter

I have already struggled in this problem for several days, I will be very grateful for your help!

The issue is likely that your metadata isn’t being indexed properly in Qdrant Cloud for filtering. When you create the collection with from_documents([]) (empty list), the metadata schema isn’t established.

Try this approach:

# First, create with your document to establish schema
vectorstore = QdrantVectorStore.from_documents(
    [doc],  # Include your document here
    url=os.getenv("QDRANT_ENDPOINT"),
    api_key=os.getenv("QDRANT_API_KEY"),
    prefer_grpc=True,
    collection_name=COLLECTION_NAME,
    embedding=embedding,
)

# Then test search without the complex filter first
test_docs = vectorstore.similarity_search("paracetamol", k=1)
print(f"Found {len(test_docs)} docs")

# If that works, try simpler filter syntax
test_docs = vectorstore.similarity_search(
    "test", 
    k=1,
    filter={"source": "QnA"}  # Simplified filter
)

Also check your Qdrant Cloud collection in the web console to verify the metadata fields are properly indexed.