Skip to content
reaatechREAATECH

@reaatech/hybrid-rag-qdrant

npm v0.1.0

Provides a wrapper class for the Qdrant REST client that simplifies collection management, batch upserting, and metadata-filtered vector searches. It acts as an abstraction layer over `@qdrant/js-client-rest` to streamline common RAG operations.

@reaatech/hybrid-rag-qdrant

npm version License: MIT CI

Status: Pre-1.0 — APIs may change in minor versions. Pin to a specific version in production.

Qdrant vector database adapter for hybrid RAG systems. Provides a clean wrapper around @qdrant/js-client-rest with collection management, batch upsert, vector search with metadata filtering, and health checks.

Installation

terminal
npm install @reaatech/hybrid-rag-qdrant
# or
pnpm add @reaatech/hybrid-rag-qdrant

Feature Overview

  • Collection management — auto-create collections with configurable vector size and distance metric
  • Batch upsert — chunked ingestion with configurable batch sizes (default 100)
  • Vector search — cosine/euclidean/dot similarity with metadata filtering
  • Metadata filter builder — automatic conversion from Record<string, unknown> to Qdrant filter conditions
  • Health check — connectivity verification for container orchestration
  • Type-safe — full TypeScript support with types from @reaatech/hybrid-rag

Quick Start

typescript
import { QdrantClientWrapper } from '@reaatech/hybrid-rag-qdrant';
 
const client = new QdrantClientWrapper({
  url: 'http://localhost:6333',
  apiKey: process.env.QDRANT_API_KEY,
  collectionName: 'documents',
  vectorSize: 1536,
  distance: 'Cosine',
});
 
await client.initialize();
 
// Upsert a point
await client.upsertPoint({
  id: 'chunk-001-0',
  vector: [0.1, 0.2, /* ... */],
  payload: {
    documentId: 'doc-001',
    content: 'The quick brown fox jumps over the lazy dog.',
    index: 0,
    metadata: { source: 'wiki' },
  },
});
 
// Search
const results = await client.search({
  vector: queryEmbedding,
  topK: 10,
  filter: { department: 'engineering' },
});
 
console.log(results[0].content, results[0].score);

API Reference

QdrantClientWrapper

Constructor

typescript
new QdrantClientWrapper(config: QdrantClientConfig)

QdrantClientConfig

PropertyTypeDefaultDescription
urlstring(required)Qdrant server URL
apiKeystringAPI key for authentication
collectionNamestring(required)Default collection name
vectorSizenumber(required)Vector dimension (e.g. 1536 for text-embedding-3-small)
distanceCosine' | 'Euclid' | 'DotCosineSimilarity metric

Methods

MethodDescription
initialize()Ensure collection exists (creates if not)
collectionExists(name)Check if a named collection exists
createCollection(name, params)Create a new collection with vector params
upsertPoint(point)Upsert a single point
upsertBatch(points)Upsert points in batches of 100
search(query)Vector search returning RetrievalResult[]
deleteCollection(name)Delete a collection
getCollectionInfo(name)Get collection metadata
healthCheck()Verify Qdrant connectivity — returns boolean

QdrantPoint

PropertyTypeDescription
idstringPoint identifier (typically the chunk ID)
vectornumber[]Embedding vector
payloadRecord<string, unknown>Arbitrary metadata stored with the point

Filter Building

Metadata filters are automatically converted to Qdrant must conditions:

typescript
{ department: 'engineering', status: 'published' }
// Becomes → { must: [{ key: 'department', match: { value: 'engineering' } }, ...] }

Choosing a Distance Metric

MetricBest ForDescription
CosineText embeddingsMeasures angle between vectors (default, recommended for most LLM embeddings)
EuclidDense vectorsStraight-line distance in vector space
DotNormalized vectorsEquivalent to cosine similarity when vectors are normalized

License

MIT