Documentation
¶
Overview ¶
Package qdrant implements vectorstore.VectorStore using Qdrant's REST API -- the project's non-SQL exemplar for vector backends, same role Mongo plays for state.Store -- proof the vectorstore.VectorStore interface is implementable against a real standalone vector database, not just pgvector's SQL extension).
Plain net/http against Qdrant's REST API rather than the official gRPC client (github.com/qdrant/go-client): Qdrant's REST surface is small, stable, and documented directly as JSON -- pulling in a generated gRPC client for four HTTP calls would be a heavier dependency than the problem needs.
One collection holds every tenant/namespace (not one collection per tenant or namespace): tenant_id and namespace are stored as payload fields and included in every filter, the same "always scope by tenant_id/namespace in the WHERE clause" shape pgvector uses. Qdrant point IDs must be an unsigned integer or a UUID -- never an arbitrary string -- so a caller's (tenant_id, namespace, id) is mapped to a deterministic UUID v5 (same triple always produces the same point ID, making upsert-by-id and delete-by-id idempotent) while the original three values are kept in the payload for retrieval.
Index ¶
- type Store
- func (s *Store) Close() error
- func (s *Store) Delete(ctx context.Context, namespace, id string) error
- func (s *Store) Init(ctx context.Context) error
- func (s *Store) Search(ctx context.Context, req *models.VectorSearchRequest) ([]*models.VectorSearchResult, error)
- func (s *Store) Upsert(ctx context.Context, item *models.VectorItem) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store implements vectorstore.VectorStore against a Qdrant instance.
func New ¶
New creates a Qdrant-backed store. dimensions fixes the collection's vector size at creation time, same fixed-width convention as pgvector's vector(N) column -- every item upserted must supply exactly this many floats, checked before any HTTP call is made.
func (*Store) Init ¶
Init creates the collection if it doesn't already exist. Safe to call on every startup -- Qdrant's create-collection endpoint 409s on an existing collection, which is treated as success. Intentionally not a numbered migration trail (unlike pgvector): Qdrant has no evolvable DDL; payload fields are schemaless.
Known limitation, same shape as pgvector's: the collection's vector size is fixed the first time it's created. Changing vector_store.dimensions in langgraph.json after the collection already exists does not migrate it -- Upsert starts failing loudly with a clear Qdrant dimension-mismatch error until the collection is manually dropped or recreated with the new size.
func (*Store) Search ¶
func (s *Store) Search(ctx context.Context, req *models.VectorSearchRequest) ([]*models.VectorSearchResult, error)
func (*Store) Upsert ¶
Upsert's created_at is a known, stated limitation: Qdrant has no built-in insert-vs-update distinction the way Postgres's ON CONFLICT DO UPDATE does, so pinning down "first write time" would need a read before every write to check whether the point already exists. created_at is set to "now" on every Upsert call, including a re-index of an already-existing id -- correct for a fresh item, but re-indexing an existing document resets its created_at rather than preserving the original. Upgrade path: a GET on the point's id before the upsert, reusing its existing created_at when present.