weaviate

package
v0.9.21 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

Adapter wraps the existing Weaviate client to implement the VectorDBClient interface

func NewAdapter

func NewAdapter(config *vectordb.Config) (*Adapter, error)

NewAdapter creates a new Weaviate adapter

func (*Adapter) Close added in v0.8.1

func (a *Adapter) Close() error

Close closes the Weaviate adapter and cleans up resources Note: Weaviate Go SDK uses HTTP/REST client which doesn't require explicit cleanup HTTP connections are managed by the Go HTTP transport and closed when no longer needed

func (*Adapter) CollectionExists

func (a *Adapter) CollectionExists(ctx context.Context, name string) (bool, error)

CollectionExists checks if a collection exists

func (*Adapter) CreateCollection

func (a *Adapter) CreateCollection(ctx context.Context, name string, schema *vectordb.CollectionSchema) error

CreateCollection creates a new collection with the given schema

func (*Adapter) CreateDocument

func (a *Adapter) CreateDocument(ctx context.Context, collectionName string, document *vectordb.Document) error

CreateDocument creates a new document in the specified collection

func (*Adapter) CreateDocuments

func (a *Adapter) CreateDocuments(ctx context.Context, collectionName string, documents []*vectordb.Document) error

CreateDocuments creates multiple documents in batch

func (*Adapter) DeleteCollection

func (a *Adapter) DeleteCollection(ctx context.Context, name string) error

DeleteCollection deletes a collection and all its documents

func (*Adapter) DeleteDocument

func (a *Adapter) DeleteDocument(ctx context.Context, collectionName, documentID string) error

DeleteDocument deletes a document by ID

func (*Adapter) DeleteDocuments

func (a *Adapter) DeleteDocuments(ctx context.Context, collectionName string, documentIDs []string) error

DeleteDocuments deletes multiple documents by IDs

func (*Adapter) DeleteDocumentsByMetadata

func (a *Adapter) DeleteDocumentsByMetadata(ctx context.Context, collectionName string, metadata map[string]interface{}) error

DeleteDocumentsByMetadata deletes documents matching metadata criteria

func (*Adapter) GetCollectionCount

func (a *Adapter) GetCollectionCount(ctx context.Context, name string) (int64, error)

GetCollectionCount returns the number of documents in a collection

func (*Adapter) GetDefaultSchema

func (a *Adapter) GetDefaultSchema(schemaType vectordb.SchemaType, collectionName string) *vectordb.CollectionSchema

GetDefaultSchema returns a default schema for the given type

func (*Adapter) GetDocument

func (a *Adapter) GetDocument(ctx context.Context, collectionName, documentID string) (*vectordb.Document, error)

GetDocument retrieves a document by ID

func (*Adapter) GetSchema

func (a *Adapter) GetSchema(ctx context.Context, collectionName string) (*vectordb.CollectionSchema, error)

GetSchema retrieves the schema for a collection

func (*Adapter) Health

func (a *Adapter) Health(ctx context.Context) error

Health checks the health of the Weaviate instance

func (*Adapter) ListCollections

func (a *Adapter) ListCollections(ctx context.Context) ([]vectordb.CollectionInfo, error)

ListCollections returns a list of all collections

func (*Adapter) ListDocuments

func (a *Adapter) ListDocuments(ctx context.Context, collectionName string, limit int, offset int) ([]*vectordb.Document, error)

ListDocuments returns a list of documents in a collection

func (*Adapter) SearchBM25

func (a *Adapter) SearchBM25(ctx context.Context, collectionName, query string, options *vectordb.QueryOptions) ([]*vectordb.QueryResult, error)

SearchBM25 performs keyword-based search using BM25

func (*Adapter) SearchByMetadata

func (a *Adapter) SearchByMetadata(ctx context.Context, collectionName string, metadata map[string]interface{}, options *vectordb.QueryOptions) ([]*vectordb.QueryResult, error)

SearchByMetadata searches documents by metadata fields

func (*Adapter) SearchHybrid

func (a *Adapter) SearchHybrid(ctx context.Context, collectionName, query string, options *vectordb.QueryOptions) ([]*vectordb.QueryResult, error)

SearchHybrid performs hybrid search combining vector and keyword search

func (*Adapter) SearchSemantic

func (a *Adapter) SearchSemantic(ctx context.Context, collectionName, query string, options *vectordb.QueryOptions) ([]*vectordb.QueryResult, error)

SearchSemantic performs semantic search using vector embeddings

func (*Adapter) UpdateDocument

func (a *Adapter) UpdateDocument(ctx context.Context, collectionName string, document *vectordb.Document) error

UpdateDocument updates an existing document

func (*Adapter) UpdateSchema

func (a *Adapter) UpdateSchema(ctx context.Context, collectionName string, schema *vectordb.CollectionSchema) error

UpdateSchema updates the schema for a collection

func (*Adapter) ValidateSchema

func (a *Adapter) ValidateSchema(schema *vectordb.CollectionSchema) error

ValidateSchema validates a schema definition

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client wraps the Weaviate client with additional functionality

func NewClient

func NewClient(config *Config) (*Client, error)

NewClient creates a new Weaviate client

func (*Client) CountDocuments

func (c *Client) CountDocuments(ctx context.Context, collectionName string) (int, error)

CountDocuments efficiently counts documents in a collection without fetching content This is much faster than ListDocuments for large collections with heavy data

func (*Client) CreateCollection

func (c *Client) CreateCollection(ctx context.Context, collectionName, embeddingModel string, customFields []FieldDefinition) error

CreateCollection creates a new collection with the specified schema

func (*Client) CreateCollectionFromSchema

func (c *Client) CreateCollectionFromSchema(ctx context.Context, schema *CollectionSchema) error

CreateCollectionFromSchema creates a collection from a CollectionSchema object

func (*Client) CreateCollectionWithSchema

func (c *Client) CreateCollectionWithSchema(ctx context.Context, collectionName, embeddingModel string, customFields []FieldDefinition, schemaType string) error

CreateCollectionWithSchema creates a new collection with the specified schema type

func (*Client) CreateDocument

func (c *Client) CreateDocument(ctx context.Context, collectionName string, doc Document) error

CreateDocument creates a new document in the specified collection

func (*Client) DeleteAllDocuments

func (c *Client) DeleteAllDocuments(ctx context.Context, collectionName string) error

DeleteAllDocuments deletes all documents in a collection

func (*Client) DeleteCollection

func (c *Client) DeleteCollection(ctx context.Context, collectionName string) error

DeleteCollection deletes all objects from a collection

func (*Client) DeleteCollectionSchema

func (c *Client) DeleteCollectionSchema(ctx context.Context, collectionName string) error

DeleteCollectionSchema deletes the collection schema completely

func (*Client) DeleteDocument

func (c *Client) DeleteDocument(ctx context.Context, collectionName, documentID string) error

DeleteDocument deletes a specific document by ID

func (*Client) DeleteDocumentsBulk

func (c *Client) DeleteDocumentsBulk(ctx context.Context, collectionName string, documentIDs []string) (int, error)

DeleteDocumentsBulk deletes multiple documents using concurrent individual requests for better performance

func (*Client) DeleteDocumentsByMetadata

func (c *Client) DeleteDocumentsByMetadata(ctx context.Context, collectionName string, metadataFilters []string) (int, error)

DeleteDocumentsByMetadata deletes documents matching metadata filters using REST API

func (*Client) GetCollectionCount added in v0.9.2

func (c *Client) GetCollectionCount(ctx context.Context, collectionName string) (int64, error)

GetCollectionCount returns the number of objects in a collection using GraphQL Aggregate

func (*Client) GetCollectionSchema

func (c *Client) GetCollectionSchema(ctx context.Context, collectionName string) ([]string, error)

GetCollectionSchema returns the schema for a collection

func (*Client) GetDocument

func (c *Client) GetDocument(ctx context.Context, collectionName, documentID string) (*Document, error)

GetDocument retrieves a specific document by ID using REST API

func (*Client) GetDocumentsByMetadata

func (c *Client) GetDocumentsByMetadata(ctx context.Context, collectionName string, metadataFilters []string) ([]Document, error)

GetDocumentsByMetadata gets documents matching metadata filters

func (*Client) GetFullCollectionSchema

func (c *Client) GetFullCollectionSchema(ctx context.Context, collectionName string) (*CollectionSchema, error)

GetFullCollectionSchema returns the full schema for a collection

func (*Client) Health

func (c *Client) Health(ctx context.Context) error

Health checks the health of the Weaviate instance

func (*Client) ListCollections

func (c *Client) ListCollections(ctx context.Context) ([]string, error)

ListCollections returns a list of all collections

func (*Client) ListDocuments

func (c *Client) ListDocuments(ctx context.Context, collectionName string, limit int) ([]Document, error)

ListDocuments returns a list of documents in a collection Note: Currently shows document IDs only. To show actual document content/metadata, we would need to implement dynamic schema discovery for each collection.

func (*Client) Query

func (c *Client) Query(ctx context.Context, collectionName, queryText string, options QueryOptions) ([]QueryResult, error)

Query performs semantic search on a collection using nearText

func (*Client) QueryWithFilters

func (c *Client) QueryWithFilters(ctx context.Context, collectionName, queryText string, options QueryOptions, filters map[string]interface{}) ([]QueryResult, error)

QueryWithFilters performs semantic search with additional metadata filters

func (*Client) UpdateDocument

func (c *Client) UpdateDocument(ctx context.Context, collectionName, documentID, content string, metadata map[string]interface{}) error

UpdateDocument updates an existing document in Weaviate

type CollectionSchema

type CollectionSchema struct {
	Class      string           `json:"class"`
	Vectorizer string           `json:"vectorizer,omitempty"`
	Properties []SchemaProperty `json:"properties"`
}

CollectionSchema represents a collection schema

type Config

type Config struct {
	URL          string
	APIKey       string
	OpenAIAPIKey string
	Timeout      int // Timeout in seconds for operations (default: 10)
}

Config holds Weaviate client configuration

type Document

type Document struct {
	ID        string                 `json:"id"`
	Text      string                 `json:"text"`
	Content   string                 `json:"content"`
	Image     string                 `json:"image"`
	ImageData string                 `json:"image_data"`
	URL       string                 `json:"url"`
	Metadata  map[string]interface{} `json:"metadata"`
}

Document represents a document in Weaviate

type Factory

type Factory struct{}

Factory implements the ClientFactory interface for Weaviate

func NewFactory

func NewFactory() *Factory

NewFactory creates a new Weaviate factory

func (*Factory) CreateClient

func (f *Factory) CreateClient(config *vectordb.Config) (vectordb.VectorDBClient, error)

CreateClient creates a new Weaviate client

func (*Factory) GetSupportedTypes

func (f *Factory) GetSupportedTypes() []vectordb.VectorDBType

GetSupportedTypes returns the list of supported database types

func (*Factory) ValidateConfig

func (f *Factory) ValidateConfig(config *vectordb.Config) error

ValidateConfig validates the configuration for Weaviate

type FieldDefinition

type FieldDefinition struct {
	Name string
	Type string
}

FieldDefinition represents a field in a collection

type ObjectInfo

type ObjectInfo struct {
	ID string
}

ObjectInfo represents basic object information

type QueryOptions

type QueryOptions struct {
	TopK           int     `json:"top_k"`
	TopKImages     int     `json:"top_k_images"` // Number of results from image collections (0 = use TopK)
	Distance       float64 `json:"distance"`
	SearchMetadata bool    `json:"search_metadata"`
	NoTruncate     bool    `json:"no_truncate"`
	UseBM25        bool    `json:"use_bm25"`
	JSONOutput     bool    `json:"json_output"`
	ImageQuery     string  `json:"image_query"`      // Base64 encoded image for nearImage search
	UseImageVector bool    `json:"use_image_vector"` // Use image_vector instead of text_vector
	IncludeImages  bool    `json:"include_images"`   // Include base64 image data in JSON output
	Verbose        bool    `json:"verbose"`          // Enable debug logging
}

QueryOptions holds options for semantic search queries

type QueryResult

type QueryResult struct {
	ID       string                 `json:"id"`
	Content  string                 `json:"content"`
	Metadata map[string]interface{} `json:"metadata"`
	Score    float64                `json:"score"`
}

QueryResult represents the result of a semantic search query

type SchemaProperty

type SchemaProperty struct {
	Name             string                 `json:"name" yaml:"name"`
	DataType         []string               `json:"dataType" yaml:"datatype"`
	Description      string                 `json:"description,omitempty" yaml:"description,omitempty"`
	NestedProperties []SchemaProperty       `json:"nestedProperties,omitempty" yaml:"nestedproperties,omitempty"`
	JSONSchema       map[string]interface{} `json:"json_schema,omitempty" yaml:"json_schema,omitempty"`
}

SchemaProperty represents a property in a collection schema

type SchemaType

type SchemaType string

SchemaType represents the type of collection schema

const (
	SchemaTypeText  SchemaType = "text"
	SchemaTypeImage SchemaType = "image"
)

type WeaveClient

type WeaveClient struct {
	*Client
	// contains filtered or unexported fields
}

WeaveClient wraps the official Weaviate client with additional functionality

func NewWeaveClient

func NewWeaveClient(config *Config) (*WeaveClient, error)

NewWeaveClient creates a new Weave client with enhanced functionality

func (*WeaveClient) CountDocuments

func (wc *WeaveClient) CountDocuments(ctx context.Context, collectionName string) (int, error)

CountDocuments delegates to the official client

func (*WeaveClient) CreateCollection

func (wc *WeaveClient) CreateCollection(ctx context.Context, collectionName, embeddingModel string, customFields []FieldDefinition) error

CreateCollection delegates to the official client

func (*WeaveClient) CreateCollectionWithSchema

func (wc *WeaveClient) CreateCollectionWithSchema(ctx context.Context, collectionName, embeddingModel string, customFields []FieldDefinition, schemaType string) error

func (*WeaveClient) CreateDocument

func (wc *WeaveClient) CreateDocument(ctx context.Context, collectionName string, document Document) error

CreateDocument creates a new document in the specified collection

func (*WeaveClient) DeleteAllDocuments

func (wc *WeaveClient) DeleteAllDocuments(ctx context.Context, collectionName string) error

DeleteAllDocuments deletes all documents in a collection

func (*WeaveClient) DeleteCollection

func (wc *WeaveClient) DeleteCollection(ctx context.Context, collectionName string) error

DeleteCollection deletes all objects from a collection

func (*WeaveClient) DeleteCollectionSchema

func (wc *WeaveClient) DeleteCollectionSchema(ctx context.Context, collectionName string) error

DeleteCollectionSchema deletes the collection schema completely

func (*WeaveClient) DeleteDocument

func (wc *WeaveClient) DeleteDocument(ctx context.Context, collectionName, documentID string) error

DeleteDocument deletes a specific document by ID using REST API

func (*WeaveClient) DeleteDocumentsBulk

func (wc *WeaveClient) DeleteDocumentsBulk(ctx context.Context, collectionName string, documentIDs []string) (int, error)

DeleteDocumentsBulk deletes multiple documents in a single batch operation

func (*WeaveClient) DeleteDocumentsByMetadata

func (wc *WeaveClient) DeleteDocumentsByMetadata(ctx context.Context, collectionName string, metadataFilters []string) (int, error)

DeleteDocumentsByMetadata deletes documents matching metadata filters using REST API

func (*WeaveClient) GetCollectionSchema

func (wc *WeaveClient) GetCollectionSchema(ctx context.Context, collectionName string) ([]string, error)

GetCollectionSchema delegates to the official client

func (*WeaveClient) GetDocument

func (wc *WeaveClient) GetDocument(ctx context.Context, collectionName, documentID string) (*Document, error)

GetDocument delegates to the official client

func (*WeaveClient) GetDocumentsByMetadata

func (wc *WeaveClient) GetDocumentsByMetadata(ctx context.Context, collectionName string, metadataFilters []string) ([]Document, error)

GetDocumentsByMetadata gets documents matching metadata filters

func (*WeaveClient) Health

func (wc *WeaveClient) Health(ctx context.Context) error

Health delegates to the official client

func (*WeaveClient) ListCollections

func (wc *WeaveClient) ListCollections(ctx context.Context) ([]string, error)

ListCollections delegates to the official client

func (*WeaveClient) ListDocuments

func (wc *WeaveClient) ListDocuments(ctx context.Context, collectionName string, limit int) ([]Document, error)

ListDocuments delegates to the official client

Jump to

Keyboard shortcuts

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