qdrant

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package qdrant keeps vectors in Qdrant, over its JSON HTTP API.

It exists to prove that store.Vector is a real seam and not a shape only an in-memory map can fill: nothing here is imported by the rest of semantica, and a program reaches it the way a program reaches a database driver.

import _ "github.com/hanzoai/semantic/store/qdrant"

v, err := store.Vectors.Open("qdrant", "http://localhost:6333/docs")

The API is spoken directly rather than through a client library, so the module stays on the standard library and the requests are the ones a reader can check against Qdrant's own documentation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store struct {
	// URL is the server, without a path: http://localhost:6333.
	URL string
	// Collection is the collection points are written to and read from.
	Collection string
	// Key is sent as the api-key header. Empty sends none.
	Key string
	// Metric is how Create configures the collection to measure nearness.
	// Empty means cosine.
	Metric store.Metric
	// HTTP is the client used for every request. Nil uses
	// http.DefaultClient.
	HTTP *http.Client
}

Store is one Qdrant collection.

func New

func New(dsn string) (*Store, error)

New reads a store from a URL whose last path segment names the collection, so one string carries both the server and what to ask it:

http://localhost:6333/docs
https://key@qdrant.internal:6333/docs

A user in the URL is sent as the api-key header.

func (*Store) Add

func (s *Store) Add(ctx context.Context, items ...store.Item) error

Add writes many vectors in one request, which is the reason to have it: a point per round trip is the wrong price for a batch.

func (*Store) Count

func (s *Store) Count(ctx context.Context) (int, error)

Count reports how many points the collection holds, counted exactly rather than estimated.

func (*Store) Create

func (s *Store) Create(ctx context.Context, dim int) error

Create makes the collection, sized for vectors of dim components and measuring nearness the way the store does. It is not needed to use a collection that already exists.

func (*Store) Drop

func (s *Store) Drop(ctx context.Context, ids ...string) error

Drop removes points by id.

func (*Store) Get

func (s *Store) Get(ctx context.Context, ids ...string) ([]store.Item, error)

Get returns the vectors and payloads stored under a set of ids, in whatever order Qdrant answers.

func (*Store) Near

func (s *Store) Near(ctx context.Context, v []float32, k int) ([]store.Match, error)

Near returns the k nearest vectors to v, nearest first.

func (*Store) Put

func (s *Store) Put(ctx context.Context, id string, v []float32, meta map[string]any) error

Put writes one vector under an id, replacing whatever was there.

func (*Store) Search

func (s *Store) Search(ctx context.Context, q store.Query) ([]store.Match, error)

Search returns the k nearest vectors that also match the query's filter, which Qdrant applies while it searches rather than after.

Scores are Qdrant's own, on the collection's metric: a cosine collection answers with cosine similarity, exactly as store.Mem does, so the two stores rank alike and a score means the same thing whichever served it.

A K of zero or less asks for ten. Unlike Mem, the server has no way to be asked for everything, and pretending otherwise would answer a different question than the one put to it.

A collection measures nearness one way, fixed when it was created, so a query that asks for a different metric is refused rather than answered on the wrong one.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL