weaviate

package
v0.2.44 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package weaviate provides a Weaviate-based implementation of the GraphRAG interface.

This implementation stores entities and relationships in separate Weaviate collections, using vector embeddings for semantic search and metadata filtering for graph traversal.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Host is the hostname of the Weaviate server (e.g., "localhost:8080")
	Host string

	// Scheme is the URL scheme ("http" or "https")
	Scheme string

	// APIKey is the authentication key for Weaviate Cloud
	APIKey string

	// ClassPrefix is the prefix for entity/relationship collections (default: "Graph")
	ClassPrefix string
}

Config holds configuration for the Weaviate GraphRAG store.

type Option

type Option func(*Store)

Option represents an option for configuring the Store.

func WithClassPrefix

func WithClassPrefix(prefix string) Option

WithClassPrefix sets the class prefix for entity/relationship collections.

func WithEmbedder

func WithEmbedder(embedder embedding.Client) Option

WithEmbedder sets the embedder for generating vectors.

func WithLogger

func WithLogger(logger logging.Logger) Option

WithLogger sets the logger for the store.

func WithSchema

func WithSchema(schema *interfaces.GraphSchema) Option

WithSchema sets an initial schema for the store.

func WithStoreTenant

func WithStoreTenant(tenant string) Option

WithStoreTenant sets the default tenant.

type Store

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

Store implements the GraphRAGStore interface using Weaviate as the backend.

func New

func New(config *Config, options ...Option) (*Store, error)

New creates a new Weaviate GraphRAG store.

func (*Store) ApplySchema

func (s *Store) ApplySchema(ctx context.Context, schema interfaces.GraphSchema) error

ApplySchema stores the schema definition for use in extraction and validation.

func (*Store) Close

func (s *Store) Close() error

Close closes the store connection. Note: Weaviate client doesn't require explicit closing.

func (*Store) CountAllEntities

func (s *Store) CountAllEntities(ctx context.Context) (int, error)

CountAllEntities is a diagnostic method that counts all entities without any filter. This is useful for debugging to verify data is actually stored.

func (*Store) DeleteEntity

func (s *Store) DeleteEntity(ctx context.Context, id string, opts ...interfaces.GraphStoreOption) error

DeleteEntity deletes an entity by its ID.

func (*Store) DeleteRelationship

func (s *Store) DeleteRelationship(ctx context.Context, id string, opts ...interfaces.GraphStoreOption) error

DeleteRelationship deletes a relationship by its ID.

func (*Store) DeleteSchema

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

DeleteSchema deletes the entity and relationship collections. Use with caution - this will delete all data!

func (*Store) DiscoverSchema

func (s *Store) DiscoverSchema(ctx context.Context) (*interfaces.GraphSchema, error)

DiscoverSchema infers schema from existing data in the graph.

func (*Store) ExtractFromText

func (s *Store) ExtractFromText(ctx context.Context, text string, llm interfaces.LLM, opts ...interfaces.ExtractionOption) (*interfaces.ExtractionResult, error)

ExtractFromText extracts entities and relationships from text using an LLM.

func (*Store) GetEntity

func (s *Store) GetEntity(ctx context.Context, id string, opts ...interfaces.GraphStoreOption) (*interfaces.Entity, error)

GetEntity retrieves an entity by its ID.

func (*Store) GetRelationships

func (s *Store) GetRelationships(ctx context.Context, entityID string, direction interfaces.RelationshipDirection, opts ...interfaces.GraphSearchOption) ([]interfaces.Relationship, error)

GetRelationships retrieves relationships for an entity based on direction.

func (*Store) GetTenant

func (s *Store) GetTenant() string

GetTenant returns the current tenant.

func (*Store) GlobalSearch

func (s *Store) GlobalSearch(ctx context.Context, query string, communityLevel int, opts ...interfaces.GraphSearchOption) ([]interfaces.GraphSearchResult, error)

GlobalSearch performs a community-based search across the knowledge graph. It groups entities by type and searches across communities.

func (*Store) ListAllEntities

func (s *Store) ListAllEntities(ctx context.Context, limit int) ([]interfaces.Entity, error)

ListAllEntities is a diagnostic method that lists all entities without any filter.

func (*Store) LocalSearch

func (s *Store) LocalSearch(ctx context.Context, query string, entityID string, depth int, opts ...interfaces.GraphSearchOption) ([]interfaces.GraphSearchResult, error)

LocalSearch performs a search starting from a specific entity and traversing the graph.

func (*Store) Search

func (s *Store) Search(ctx context.Context, query string, limit int, opts ...interfaces.GraphSearchOption) ([]interfaces.GraphSearchResult, error)

Search performs a search on the knowledge graph. It supports vector, keyword, and hybrid search modes.

func (*Store) SetTenant

func (s *Store) SetTenant(tenant string)

SetTenant sets the current tenant for multi-tenancy operations.

func (*Store) ShortestPath

func (s *Store) ShortestPath(ctx context.Context, sourceID, targetID string, opts ...interfaces.GraphSearchOption) (*interfaces.GraphPath, error)

ShortestPath finds the shortest path between two entities using BFS.

func (*Store) StoreEntities

func (s *Store) StoreEntities(ctx context.Context, entities []interfaces.Entity, opts ...interfaces.GraphStoreOption) error

StoreEntities stores multiple entities in the knowledge graph.

func (*Store) StoreRelationships

func (s *Store) StoreRelationships(ctx context.Context, relationships []interfaces.Relationship, opts ...interfaces.GraphStoreOption) error

StoreRelationships stores multiple relationships in the knowledge graph.

func (*Store) TraverseFrom

func (s *Store) TraverseFrom(ctx context.Context, entityID string, depth int, opts ...interfaces.GraphSearchOption) (*interfaces.GraphContext, error)

TraverseFrom performs a breadth-first traversal from a starting entity. Note: Weaviate doesn't support native graph traversal, so this requires multiple queries (one per hop level).

func (*Store) UpdateEntity

func (s *Store) UpdateEntity(ctx context.Context, entity interfaces.Entity, opts ...interfaces.GraphStoreOption) error

UpdateEntity updates an existing entity.

Jump to

Keyboard shortcuts

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