class Qdrant::Collection

Overview

Stable facade over a Qdrant collection — the RAG working set (~5 ops).

Anti-corruption layer: request construction (the generated CreateCollection/ VectorParams/… models) is confined to this class, as is Response(T) unwrapping (#count, #search, exists?). The public API (Collection, Hit) depends on no generated type.

Defined in:

qdrant/collection.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(name : String, url : String = ENV["QDRANT_URL"], api_key : String | Nil = nil) #

Happy path: a remote / Cloud Qdrant → HTTPS + api-key header (Qdrant's auth, not a bearer token). One dedicated collection per corpus keeps ids isolated.


[View source]

Instance Method Detail

def count : Int64 #

POST /collections/{name}/points/count with exact: true — a reliable count, used for parity and to detect divergence from the durable source.


[View source]
def delete(ids : Array(Int64)) : Nil #

POST /collections/{name}/points/delete — delete by id. The caller owns the ids (its durable source of truth); KNN is never filtered.


[View source]
def delete : Nil #

DELETE /collections/{name} — drops the collection (the caller's clear). Tolerates absence (used in spec teardown).


[View source]
def ensure(dim : Int32, distance : Symbol = :cosine) : Nil #

PUT /collections/{name} — collections.update in the generated layer. Idempotent: a no-op when the collection already exists.


[View source]
def name : String #

[View source]
def search(vector : Array(Float32), top_k : Int32 = 20) : Array(Hit) #

POST /collections/{name}/points/query — bare KNN (no filter). The Response → result.points unwrapping is confined here; the generated → home-grown type conversion lives in Hit.from. Any fusion is the caller's job.


[View source]
def upsert(id : Int64, vector : Array(Float32), payload : Hash(String, JSON::Any) = {} of String => JSON::Any) : Nil #

PUT /collections/{name}/points — collections.points.bulk_update in the generated layer. Single upsert (payload optional and minimal for RAG: hydration stays with the caller).


[View source]
def upsert(points : Array) : Nil #

Batch upsert: an array of {id, vector} tuples.


[View source]