Documentation
¶
Overview ¶
Package weaviate stores prepared vectors in a Weaviate collection through the official gRPC protocol. Server metadata, schema, and deletion use one HTTP origin that rejects redirects. Search and batch writes address the configured gRPC server directly. HTTPS enables certificate verification on both transports. The Host closes the client. Provision exactly one self-provided dense vector named "embedding": its collection description must equal the bound SpaceID.StorageKey(). Use HNSW, flat or dynamic with an explicit distance. The REST schema supplies the native flags and distance. Multi-tenancy, reference properties and multivectors are not supported by this binding.
The same object owns content (searchable word text), metadata (field text) and metadataTerms (filterable field text[]). The metadata cell preserves exact business JSON and source provenance. Only business fields contribute to the native terms. Filters outside the equivalent subset fail before search.
A gRPC batch reply identifies rejections by position. Omitted indices are acknowledged only after a completed reply; a transport failure leaves the submitted group unconfirmed. Acknowledgment is distinct from search visibility. NearVector and Hybrid each issue one native search. Hybrid uses the supplied lexical text and coordinates in a single relative-score fusion; an absent alpha leaves the server default intact. DeleteIDs removes named UUIDs only. Missing native identities, vectors, scores or source evidence invalidate the entire result. No operation falls back to enumeration. Unexpected REST statuses retain HTTP status and safe request identity through core/httpclient.ResponseError; DELETE accepts both 204 and 404 as success.
The integration suite requires an isolated server and provisions disposable collections. A local protocol peer exercises both transports in ordinary tests.
Index ¶
- Constants
- Variables
- type Client
- type ClientConfig
- type Store
- func (s *Store) CheckDocuments(ctx context.Context, space vectorstore.SpaceID, docs []*document.Document) error
- func (s *Store) CheckQuery(ctx context.Context, space vectorstore.SpaceID, o vectorstore.SearchOptions) error
- func (s *Store) DeleteIDs(ctx context.Context, ids []string) error
- func (s *Store) Query(ctx context.Context, request *vectorstore.Query) (response *vectorstore.SearchResponse, err error)
- func (s *Store) Upsert(ctx context.Context, b *vectorstore.Batch) error
- type StoreConfig
Examples ¶
Constants ¶
const (
Provider = "Weaviate"
)
Variables ¶
var ( ErrMissingClient = errors.New("weaviate: Client is required") ErrUninitializedClient = errors.New("weaviate: Client must be created with NewClient") ErrMissingCollection = errors.New("weaviate: Collection is required") ErrInvalidObjectID = errors.New("weaviate: invalid object ID") ErrIncompatibleCollection = errors.New("weaviate: existing collection is incompatible") )
Functions ¶
This section is empty.
Types ¶
type Client ¶ added in v0.59.0
type Client struct {
// contains filtered or unexported fields
}
Client binds all REST operations to one origin and gRPC calls to one configured server. Multiple stores can borrow the connection. The Host closes it after use.
type ClientConfig ¶ added in v0.59.0
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func NewStore ¶
func NewStore(ctx context.Context, config StoreConfig) (*Store, error)
Example ¶
package main
import (
"context"
"time"
"github.com/Tangerg/scope/core/document"
"github.com/Tangerg/scope/core/vectorstore"
"github.com/Tangerg/scope/vectorstores/weaviate"
)
func main() {
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()
client, err := weaviate.NewClient(ctx, weaviate.ClientConfig{Endpoint: "http://localhost:8080", GRPCAddress: "localhost:50051"})
if err != nil {
panic(err)
}
// The host has provisioned the current native collection described in GoDoc.
defer client.Close()
store, err := weaviate.NewStore(ctx, weaviate.StoreConfig{Client: client, Collection: "Documents", Space: "paired-v1"})
if err != nil {
panic(err)
}
id := "f9168c5e-ceb2-4faa-b6bf-329bf39fa1e4"
if err = store.Upsert(ctx, &vectorstore.Batch{Space: "paired-v1", Records: []vectorstore.Record{{Document: &document.Document{ID: id, Text: "hello"}, Values: []float64{1, 0}}}}); err != nil {
panic(err)
}
if _, err = store.Query(ctx, &vectorstore.Query{Space: "paired-v1", Values: []float64{1, 0}}); err != nil {
panic(err)
}
if err = store.DeleteIDs(ctx, []string{id}); err != nil {
panic(err)
}
}
Output:
func (*Store) CheckDocuments ¶ added in v0.59.0
func (*Store) CheckQuery ¶ added in v0.59.0
func (s *Store) CheckQuery(ctx context.Context, space vectorstore.SpaceID, o vectorstore.SearchOptions) error
func (*Store) Query ¶ added in v0.59.0
func (s *Store) Query(ctx context.Context, request *vectorstore.Query) (response *vectorstore.SearchResponse, err error)
type StoreConfig ¶
type StoreConfig struct {
Client *Client
Collection string
Space vectorstore.SpaceID
// HybridAlpha selects native query fusion; nil preserves the native default.
HybridAlpha *float32
}
func (StoreConfig) Validate ¶
func (s StoreConfig) Validate() error