liveBook · Manning

Qdrant

As explained in Build an Advanced RAG Application (From Scratch)

Qdrant is an open-source vector search engine and database that supports similarity search, metadata filtering, and scalable vector indexing.

Qdrant is used as the vector database layer in a retrieval-augmented generation pipeline. It stores embedding vectors with payload metadata, retrieves semantically similar records, and can restrict retrieval with metadata filters. This replaces a FAISS-based search step when the workflow needs more scalable, targeted retrieval. section 6.2 section 6.6

A collection groups vectors and metadata much as a table groups related records. Each uploaded point has a unique ID, a vector, and a payload. For hotel reviews, the payload includes hotel name, review text, and locality; for paper chunks, it includes original content plus publication metadata. The collection configuration fixes vector size and cosine distance, so stored vectors must match the embedding model’s output dimension. section 6.2 section 6.4

Build a Qdrant-backed retrieval stage incrementally:

  • Create a client and collection with a vector size matching the embeddings and cosine distance. section 6.2 section 6.4
  • Chunk documents where needed, embed each chunk, and upload points containing vectors plus payload content and metadata. section 6.4
  • Embed a natural-language query, query the collection for a limited number of nearest points, and return payloads as retrieval context. section 6.4
  • Add a payload filter when relevance depends on a field such as city; filtering avoids searching through irrelevant records. section 6.2
  • Pass retrieved content and source details into a generation prompt to produce an answer with citations. section 6.2 section 6.4

City-filtered hotel retrieval

Store 768-dimensional hotel-review embeddings with locality in each point payload. A query such as “Amazing hotel close to everything” can search only points whose locality is Istanbul, then provide the top review payloads and similarity scores as context for a concise answer. The filter improves personalization and reduces manual sifting through results from other cities. section 6.2

def search_qdrant_with_filter(query, model, client, city=None, k=10): #A
   
    query_filter = None
    if city:
        query_filter = models.Filter( #B
            must=[
                models.FieldCondition(
                    key="locality",
                    match=models.MatchValue(value=city)
                )
            ]
        )
 
 
 
    text_hits = client.query_points(
    collection_name="hotel_reviews",  
    query=query_embedding,
    query_filter=query_filter,   
    limit=k,                             
    with_payload=True, 
).points                                 
 
 
    return text_hits

This query function shows the essential retrieval path: conditionally construct a locality filter, submit the query embedding, limit results, and return payload-bearing points. section 6.2

For production RAG, Qdrant adds persistent storage, concurrent access, and optimized retrieval beyond an experimental FAISS setup. Retrieval quality still depends on chunking, embeddings, metadata, and evaluation of retrieval and generated answers; metadata filters can improve both precision and computational efficiency. section 6.6 section 6.4

How Build an Advanced RAG Application (From Scratch) covers it

How deep it goes
Walks through collection setup, point upload, filtered querying, and generation integration without detailing Qdrant internals.
Examples
Uses city-filtered hotel reviews and 657 embedded research-paper chunks queried for dynamic synapses.
What you can do after
Build it from scratch as an in-memory Qdrant retrieval component that supplies cited context to a RAG generator.
How it connects
Connects vector embeddings, cosine similarity, metadata filtering, document chunking, RAG, FAISS, and OpenRouter.

Also explained in

Compare how 3 books explain Qdrant →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build an Advanced RAG Application (From Scratch). The section links point to the parts of the book it draws on.