Example
Qdrant — vector similarity search (no server, no key)

A real, runnable mini-project. Download it and run with Docker.

June 28, 2026

Qdrant — vector similarity search (no server, no key)

A tiny Qdrant demo: it stores a few documents in an in-memory collection — fastembed embeds them locally — then runs a nearest-neighbour query. Swap the toy docs for your own and it is a RAG retriever. No API key.

Run with Docker

cd samples/qdrant_1
docker build -t aas-qdrant .
docker run --rm aas-qdrant "tell me about young cats"

The first run downloads a small fastembed model (BAAI/bge-small-en-v1.5, ~130 MB), so it needs internet once.

Run with Docker (in a devcontainer with DooD)

In a dev container that talks to the host Docker daemon (Docker-outside-of-Docker), the attached docker run may print nothing even though it ran — the live attached stream drops output over the VM boundary. Run detached and read the logs:

cd samples/qdrant_1
docker build -t aas-qdrant .
docker logs -f "$(docker run -d aas-qdrant "tell me about young cats")"

Run locally

cd samples/qdrant_1
pip install -r requirements.txt
python app.py "tell me about young cats"

Example run

Embeddings are deterministic (fixed model + input), so the ranking is the same every run — only the first run downloads the model.

nearest to 'tell me about young cats' by score:
  kitten     0.7082
  cat        0.6450
  airplane   0.4201

Files

app.py
"""Qdrant: vector similarity search with no server and no API key.

Stores a few documents in an in-memory Qdrant collection (fastembed embeds them
locally via `models.Document`), then runs a nearest-neighbour query. Swap the
toy docs for your own and it is a RAG retriever.

Run:
    docker build -t aas-qdrant .
    docker run --rm aas-qdrant "tell me about young cats"
"""

import sys

from qdrant_client import QdrantClient, models

MODEL = "BAAI/bge-small-en-v1.5"  # fastembed default, 384-dim

DOCS = {
    "cat": "Cats are independent pets that purr and chase laser pointers.",
    "kitten": "A kitten is a young cat that loves to play and nap.",
    "airplane": "An airplane is a powered flying vehicle with fixed wings.",
    "rocket": "A rocket is propelled by ejecting exhaust gas at high speed.",
}


def main() -> None:
    query = " ".join(sys.argv[1:]) or "tell me about young cats"

    client = QdrantClient(":memory:")  # in-memory; fastembed runs locally
    client.create_collection(
        "docs",
        vectors_config=models.VectorParams(size=384, distance=models.Distance.COSINE),
    )
    client.upsert(
        "docs",
        points=[
            models.PointStruct(
                id=i,
                vector=models.Document(text=text, model=MODEL),
                payload={"label": label},
            )
            for i, (label, text) in enumerate(DOCS.items())
        ],
    )

    hits = client.query_points(
        "docs",
        query=models.Document(text=query, model=MODEL),
        limit=3,
    ).points

    print(f"nearest to {query!r} by score:")
    for h in hits:
        print(f"  {h.payload['label']:10s} {h.score:.4f}")


if __name__ == "__main__":
    main()