weaviate

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 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 weaviate implements vectorstore.VectorStore using Weaviate's REST + GraphQL APIs -- see internal/vectorstore/qdrant's package doc for the shared design principles (one shared class for every tenant/namespace, deterministic UUID v5 object IDs, plain HTTP rather than a generated client) this package follows too.

Plain net/http against Weaviate's REST API for writes (POST/PUT/DELETE /v1/objects, POST/GET /v1/schema) and its GraphQL API for vector search (nearVector + where -- Weaviate has no REST-level ANN search endpoint), rather than the official weaviate-go-client: same "small, documented HTTP surface, no generated client needed" reasoning as Qdrant's.

Weaviate's schema is fixed-property (every property and its type is declared up front), unlike Qdrant's freeform JSON payload -- so arbitrary caller-supplied Metadata is stored as a single JSON-encoded "metadata_json" text property rather than one Weaviate property per key; the schema doesn't need to change every time a caller invents a new metadata key. The trade-off: Search's Filter (exact-match over Metadata) can't be pushed down into Weaviate's own "where" clause the way tenant_id/namespace are, since Weaviate can't query inside a JSON-encoded string field. Handled by paging through nearVector's own tenant/namespace-scoped, similarity-ordered results (via GraphQL's offset) and applying the metadata filter in Go to each page, advancing until TopK matches are found or the corpus is exhausted -- exact, not a fixed-window over-fetch: a single-page over-fetch (this package's first implementation) is confirmed live to silently return an empty result when a matching item exists outside that window's own similarity ranking (e.g. TopK=1 with a filter matching only a distant vector, and >20x TopK closer non-matching ones). Paging until exhausted fixes that at the cost of more round trips for a filter that matches rarely in a large namespace -- capped at weaviateQueryMaxResults total scanned (10000, Weaviate's own default QUERY_MAXIMUM_RESULTS server-side offset+limit ceiling), beyond which this is honestly no longer exact, a real Weaviate-imposed limit on nearVector+offset pagination itself, not something this package can work around without a different, non-similarity-ordered pagination strategy.

Index

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 Weaviate instance.

func New

func New(baseURL, class string, dimensions int) (*Store, error)

New creates a Weaviate-backed store. dimensions is enforced by this package on every Upsert/Search call (checked before any HTTP call is made) -- Weaviate itself doesn't fix a vector width at the schema level the way pgvector's vector(N) column or Qdrant's collection config do, so nothing would otherwise catch a caller mixing embedding sizes within the same class.

func (*Store) Close

func (s *Store) Close() error

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, namespace, id string) error

func (*Store) Init

func (s *Store) Init(ctx context.Context) error

Init creates the class (collection) if it doesn't already exist. Checks via GET /v1/schema/{class} first (200 = already there) rather than blindly POSTing and matching an error string -- Weaviate's "class already exists" response is a generic 422 that isn't reliably distinguishable from other schema validation failures, unlike Qdrant's dedicated 409. Intentionally create-if-missing (not a numbered migration trail like pgvector) until a real property-schema evolution lands; an existing class is never patched here.

vectorizer: "none" is load-bearing, not a default left in place -- without it Weaviate runs its own configured vectorizer module against the object's properties and DISCARDS the caller-supplied vector entirely, silently breaking every embedding this store is handed.

Known limitation, same shape as pgvector's and Qdrant's: the class's vector width is fixed by whatever dimensions New was called with, the first time the class is actually created. Changing vector_store.dimensions in langgraph.json after the class already exists does not migrate it -- Weaviate has no fixed-width vector index constraint to reject a mismatched Upsert the way pgvector's column type does, so a silent width mismatch there would corrupt the index rather than error; this package's own explicit dimensions check on every Upsert/Search is what actually catches it instead.

func (*Store) Search

Search's ordering relies on Weaviate's GraphQL Get already returning nearVector hits sorted by similarity (closest first) -- Go only ever filters that sequence down (client-side metadata filter) and truncates it (TopK), never re-sorts it, so a page's relative order is preserved through to the final TopK results.

func (*Store) Upsert

func (s *Store) Upsert(ctx context.Context, item *models.VectorItem) error

Upsert's created_at is a known, stated limitation, same as Qdrant's: Weaviate's PUT /v1/objects/{class}/{id} replaces an EXISTING object (404 if missing) and POST /v1/objects fails if the object already exists (see the package's git history / Weaviate's own docs) -- neither alone is a true upsert. Delete-then-create (ignoring not-found on the delete) is simple and correct for "same ID overwrites, not duplicates," at the cost of one extra round trip versus a real upsert endpoint, and it means created_at is reset 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 loses its original created_at rather than preserving it.

Jump to

Keyboard shortcuts

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