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 ¶
- type Store
- func (s *Store) Add(ctx context.Context, items ...store.Item) error
- func (s *Store) Count(ctx context.Context) (int, error)
- func (s *Store) Create(ctx context.Context, dim int) error
- func (s *Store) Drop(ctx context.Context, ids ...string) error
- func (s *Store) Get(ctx context.Context, ids ...string) ([]store.Item, error)
- func (s *Store) Near(ctx context.Context, v []float32, k int) ([]store.Match, error)
- func (s *Store) Put(ctx context.Context, id string, v []float32, meta map[string]any) error
- func (s *Store) Search(ctx context.Context, q store.Query) ([]store.Match, error)
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 ¶
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 ¶
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 ¶
Count reports how many points the collection holds, counted exactly rather than estimated.
func (*Store) Create ¶
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) Get ¶
Get returns the vectors and payloads stored under a set of ids, in whatever order Qdrant answers.
func (*Store) Search ¶
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.