weaviate

package
v0.5.11 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package weaviate 提供 Weaviate 向量数据库集成

Weaviate 是一个开源的向量搜索引擎,支持语义搜索和混合搜索。

特性:

  • 内置向量化模块 (text2vec-openai, text2vec-cohere 等)
  • 支持 BM25 关键词搜索
  • 支持混合搜索 (向量 + 关键词)
  • GraphQL API
  • 多租户支持

使用示例:

store, err := weaviate.NewStore(ctx,
    weaviate.WithHost("localhost:8080"),
    weaviate.WithScheme("http"),
    weaviate.WithClass("Document"),
)
defer store.Close()

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Store)

Option Store 配置选项

func WithAPIKey

func WithAPIKey(apiKey string) Option

WithAPIKey 设置 API Key

func WithClass

func WithClass(className string) Option

WithClass 设置类名

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient 设置 HTTP 客户端

func WithHost

func WithHost(host string) Option

WithHost 设置 Weaviate 主机地址

func WithScheme

func WithScheme(scheme string) Option

WithScheme 设置协议 (http/https)

func WithTenant

func WithTenant(tenant string) Option

WithTenant 设置租户

func WithVectorizer

func WithVectorizer(vectorizer string) Option

WithVectorizer 设置向量化器

type Store

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

Store Weaviate 向量存储

封装 Weaviate REST API,实现 vector.Store 接口

func NewStore

func NewStore(ctx context.Context, opts ...Option) (*Store, error)

NewStore 创建 Weaviate 存储

func (*Store) Add

func (s *Store) Add(ctx context.Context, docs []vector.Document) error

Add 添加文档

func (*Store) BM25Search

func (s *Store) BM25Search(ctx context.Context, query string, topK int) ([]vector.Document, error)

BM25Search BM25 关键词搜索

func (*Store) Clear

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

Clear 清空索引

func (*Store) Close

func (s *Store) Close() error

Close 关闭连接

func (*Store) Count

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

Count 返回文档数量

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, ids []string) error

Delete 删除文档

func (*Store) Get

func (s *Store) Get(ctx context.Context, id string) (*vector.Document, error)

Get 获取指定文档

func (*Store) HybridSearch

func (s *Store) HybridSearch(ctx context.Context, query string, embedding []float32, topK int, alpha float64) ([]vector.Document, error)

HybridSearch 混合搜索 (向量 + 关键词)

func (*Store) Search

func (s *Store) Search(ctx context.Context, embedding []float32, topK int, opts ...vector.SearchOption) ([]vector.Document, error)

Search 搜索相似文档

Jump to

Keyboard shortcuts

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