TECHNOLOGIESTieInn Technologies

Vector stores: indexing and searching with Qdrant

RAG & Vector Search · 10 questions

Short notes

Key idea

A vector store holds embeddings plus their text and metadata, and finds the nearest vectors to a query fast, even among millions, using approximate nearest-neighbour indexes.

Syntax

from qdrant_client import QdrantClient
from qdrant_client.models import VectorParams, Distance, PointStruct

db = QdrantClient(":memory:")
db.create_collection("docs", vectors_config=VectorParams(size=768, distance=Distance.COSINE))
db.upsert("docs", points=[
    PointStruct(id=i, vector=v, payload={"text": t, "source": s})
    for i, (v, t, s) in enumerate(rows)
])
hits = db.query_points("docs", query=embed(question), limit=5).points
  • Payload = metadata you can filter on (department, date).
  • Alternatives: pgvector in PostgreSQL, Chroma, FAISS, managed cloud stores.

Example

5,000 chunks from support articles go into a docs collection. A question returns the 5 nearest chunks with their source URLs in milliseconds.

Traps

  • The vector size must match the embedding model (768 vs 1,536).
  • Re-embedding with a new model means rebuilding the whole collection.
  • Approximate search can miss the true nearest item now and then; fine for RAG, tune if recall matters.
  • For a few thousand chunks, NumPy is enough; you may not need a database yet.

Want the full lesson with step-by-step examples, a project and a certificate? RAG & Vector Search course, ₹180 →

Questions

Open in Code Lab5 free questions
5 questions

    Vector stores: indexing and searching with Qdrant

  1. Question 1easy

    What does a vector store add over keeping vectors in a NumPy matrix?

  2. Vector stores: indexing and searching with Qdrant

  3. Question 2hard

    Score every vector in vectors against query with the dot product and store the ids of the top 2, best first, in result.

    Store your answer in result.

  4. Vector stores: indexing and searching with Qdrant

  5. Question 3medium

    The search filters before taking the top k. What does this print?

    hits = [("a", 0.9, "Refunds"), ("b", 0.8, "Shipping"), ("c", 0.7, "Refunds"), ("d", 0.6, "Shipping")]
    shipping = [h[0] for h in hits if h[2] == "Shipping"][:1]
    print(shipping)
  6. Vector stores: indexing and searching with Qdrant

  7. Question 4medium

    You take the top 3 results first and then keep only Shipping chunks. Sometimes you get nothing. Why?

  8. Vector stores: indexing and searching with Qdrant

  9. Question 5medium

    What does this print?

    store = {}
    def upsert(id, text):
        store[id] = text
    upsert("7-1", "Refunds start within 3 days.")
    upsert("7-2", "Banks take 5 to 7 working days.")
    upsert("7-1", "Refunds start within 2 days.")
    print(len(store), store["7-1"])

5 more questions on this topic, with hints, and tests

Sign up free for 21 days of every question and test.