Qdrant (original) (raw)

Last Updated : 1 Apr, 2026

Qdrant is an open source vector database that stores embeddings and enables fast similarity search based on meaning, supporting semantic search, recommendations and RAG with low latency.

Qdrant Components

**1. Collections: A collection is a named group of points. All vectors in a collection must have the same dimensionality and use the same distance metric for similarity search. Each point contains:

**2. Distance Metrics: Defines how similarity is measured between vectors, such as Cosine, Dot product or Euclidean distance.

**3. Points: The basic data unit in Qdrant, which includes

**4. Storage Types: It offers two storage options

Implementation

Step 1: Create a Qdrant Cloud Account and get Credentials

official-website

Official Website

selections

Cluster Provider Selection

cluster

Cluster Creation

Qdrant provides one free cluster which has 1 node, 4GB Disk, 1GB RAM and 0.5vCPU. If we want to have more clusters with better specifications, Qdrant provides paid versions too.

Step 2: Find and copy the API key and URL of Cluster.

After creating the cluster, find URL.

url

Cluster Details

find the "API Keys" tab and select that.

API

API Key

Step 3: Install and Import Libraries

!pip install -q qdrant-client sentence-transformers numpy

import os

`

Step 4: Set Credentials as Environment Variables

os.environ["QDRANT_URL"] = "https://YOUR-CLUSTER-URL" os.environ["QDRANT_API_KEY"] = "YOUR-API-KEY"

`

Step 5: Initialize the Qdrant Client

from qdrant_client import QdrantClient

qdrant_url = os.environ["QDRANT_URL"] qdrant_key = os.environ["QDRANT_API_KEY"]

client = QdrantClient( url=qdrant_url, api_key=qdrant_key, ) client

`

**Output:

<qdrant_client.qdrant_client.QdrantClient at 0x7f6dc16ce090>

Step 6: Create a collection for 384-dimensional vectors with cosine distance.

from qdrant_client.http.models import VectorParams, Distance

collection = "colab_demo"

client.recreate_collection( collection_name=collection, vectors_config=VectorParams(size=384, distance=Distance.COSINE), )

`

**Output:

True

Step 7: Prepare some sample texts

Small, mixed-domain dataset to test semantic grouping and retrieval.

Python `

texts = [ "A guide to building RAG systems with Qdrant.", "Exploring hiking trails in the Alps.", "Best practices for securing APIs in production.", "How to connect Qdrant Cloud from Google Colab.", "Fine-tuning sentence transformers for domain data." ]

`

Step 8: Generate Embeddings using a Sentence Transformer

from sentence_transformers import SentenceTransformer import numpy as np from qdrant_client.http.models import PointStruct

model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2") embeddings = model.encode(texts, normalize_embeddings=True)

`

**Output:

Model-loading

Model Loading

Step 9: Update Vectors(points) with Payloads

points = [ PointStruct( id=i, vector=embeddings[i].tolist(), payload={"topic": "ai" if i in ( 0, 3, 4) else "travel" if i == 1 else "security"} ) for i in range(len(texts)) ]

client.upsert(collection_name=collection, points=points)

`

Step 10: Create a Payload Index

from qdrant_client.http.models import PayloadSchemaType

client.create_payload_index( collection_name=collection, field_name="topic", field_schema=PayloadSchemaType.KEYWORD, )

`

def explain_hits_with_confidence(result, texts): print("Top results with confidence estimate (cosine-based):") rows = [] scores = [p.score for p in result.points] smin, smax = min(scores), max(scores) for p in result.points: conf = (p.score - smin) / (smax - smin) if smax > smin else 1.0 rows.append({ "id": p.id, "score": round(p.score, 4), "confidence_0_1": round(conf, 3), "payload": p.payload, "text": texts[int(p.id)] if int(p.id) < len(texts) else "" }) from pprint import pprint pprint(rows, width=120)

explain_hits_with_confidence(result, texts)

`

**Output:

Output

Output

Applications

Qdrant is widely used in AI systems for fast and meaningful similarity search across different domains.