Documentation
¶
Index ¶
- func IsAlreadyExistsError(err error) bool
- func IsAuthenticationError(err error) bool
- func IsConnectionError(err error) bool
- func IsErrorType(err error, errorType ErrorType) bool
- func IsNotFoundError(err error) bool
- func IsSupported(dbType VectorDBType) bool
- func IsTimeoutError(err error) bool
- func IsUnsupportedError(err error) bool
- func RegisterFactory(dbType VectorDBType, factory ClientFactory)
- type ClientFactory
- type CollectionInfo
- type CollectionOperations
- type CollectionSchema
- type Config
- type Document
- type DocumentOperations
- type ErrorType
- type FieldDefinition
- type QueryOperations
- type QueryOptions
- type QueryResult
- type Registry
- type SchemaOperations
- type SchemaProperty
- type SchemaType
- type VectorDBClient
- type VectorDBError
- func ErrAlreadyExists(resource, name string) *VectorDBError
- func ErrAuthenticationFailed(message string) *VectorDBError
- func ErrConnectionFailed(message string, cause error) *VectorDBError
- func ErrInternal(message string, cause error) *VectorDBError
- func ErrInvalidConfig(message string) *VectorDBError
- func ErrInvalidQuery(message string) *VectorDBError
- func ErrInvalidSchema(message string) *VectorDBError
- func ErrNotFound(resource, name string) *VectorDBError
- func ErrQuotaExceeded(message string) *VectorDBError
- func ErrTimeout(operation string) *VectorDBError
- func ErrUnsupported(operation string) *VectorDBError
- func NewError(errorType ErrorType, message string) *VectorDBError
- func NewErrorWithCause(errorType ErrorType, message string, cause error) *VectorDBError
- func (e *VectorDBError) Error() string
- func (e *VectorDBError) Is(target error) bool
- func (e *VectorDBError) Unwrap() error
- func (e *VectorDBError) WithCollection(collection string) *VectorDBError
- func (e *VectorDBError) WithDetail(key string, value interface{}) *VectorDBError
- func (e *VectorDBError) WithDocument(document string) *VectorDBError
- type VectorDBType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsAlreadyExistsError ¶
IsAlreadyExistsError checks if an error is an already exists error
func IsAuthenticationError ¶
IsAuthenticationError checks if an error is an authentication error
func IsConnectionError ¶
IsConnectionError checks if an error is a connection error
func IsErrorType ¶
IsErrorType checks if an error is of a specific type
func IsNotFoundError ¶
IsNotFoundError checks if an error is a not found error
func IsSupported ¶
func IsSupported(dbType VectorDBType) bool
IsSupported checks if a database type is supported in the global registry
func IsTimeoutError ¶
IsTimeoutError checks if an error is a timeout error
func IsUnsupportedError ¶
IsUnsupportedError checks if an error is an unsupported operation error
func RegisterFactory ¶
func RegisterFactory(dbType VectorDBType, factory ClientFactory)
RegisterFactory registers a client factory globally
Types ¶
type ClientFactory ¶
type ClientFactory interface {
// CreateClient creates a new vector database client
CreateClient(config *Config) (VectorDBClient, error)
// GetSupportedTypes returns the list of supported database types
GetSupportedTypes() []VectorDBType
// ValidateConfig validates the configuration for the specific database type
ValidateConfig(config *Config) error
}
ClientFactory defines the interface for creating vector database clients
type CollectionInfo ¶
type CollectionInfo struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Count int64 `json:"count"`
Vectorizer string `json:"vectorizer,omitempty"`
}
CollectionInfo represents information about a collection
type CollectionOperations ¶
type CollectionOperations interface {
// CreateCollection creates a new collection with the given schema
CreateCollection(ctx context.Context, name string, schema *CollectionSchema) error
// DeleteCollection deletes a collection and all its documents
DeleteCollection(ctx context.Context, name string) error
// ListCollections returns a list of all collections
ListCollections(ctx context.Context) ([]CollectionInfo, error)
// CollectionExists checks if a collection exists
CollectionExists(ctx context.Context, name string) (bool, error)
// GetCollectionCount returns the number of documents in a collection
GetCollectionCount(ctx context.Context, name string) (int64, error)
}
CollectionOperations defines collection management operations
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 {
Type VectorDBType `yaml:"type"`
URL string `yaml:"url,omitempty"`
APIKey string `yaml:"api_key,omitempty"`
OpenAIAPIKey string `yaml:"openai_api_key,omitempty"`
Timeout int `yaml:"timeout,omitempty"`
// Mock-specific configuration
Enabled bool `yaml:"enabled,omitempty"`
SimulateEmbeddings bool `yaml:"simulate_embeddings,omitempty"`
EmbeddingDimension int `yaml:"embedding_dimension,omitempty"`
// Supabase-specific configuration
DatabaseURL string `yaml:"database_url,omitempty"`
DatabaseKey string `yaml:"database_key,omitempty"`
// Milvus-specific configuration
Address string `yaml:"address,omitempty"`
Username string `yaml:"username,omitempty"`
Password string `yaml:"password,omitempty"`
Database string `yaml:"database,omitempty"`
Tenant string `yaml:"tenant,omitempty"`
// MongoDB-specific configuration
VectorDimensions int `yaml:"vector_dimensions,omitempty"`
SimilarityMetric string `yaml:"similarity_metric,omitempty"`
}
Config represents the configuration for a vector database client
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 the vector database
type DocumentOperations ¶
type DocumentOperations interface {
// CreateDocument creates a new document in the specified collection
CreateDocument(ctx context.Context, collectionName string, document *Document) error
// CreateDocuments creates multiple documents in batch
CreateDocuments(ctx context.Context, collectionName string, documents []*Document) error
// GetDocument retrieves a document by ID
GetDocument(ctx context.Context, collectionName, documentID string) (*Document, error)
// UpdateDocument updates an existing document
UpdateDocument(ctx context.Context, collectionName string, document *Document) error
// DeleteDocument deletes a document by ID
DeleteDocument(ctx context.Context, collectionName, documentID string) error
// DeleteDocuments deletes multiple documents by IDs
DeleteDocuments(ctx context.Context, collectionName string, documentIDs []string) error
// DeleteDocumentsByMetadata deletes documents matching metadata criteria
DeleteDocumentsByMetadata(ctx context.Context, collectionName string, metadata map[string]interface{}) error
// ListDocuments returns a list of documents in a collection
ListDocuments(ctx context.Context, collectionName string, limit int, offset int) ([]*Document, error)
}
DocumentOperations defines document management operations
type ErrorType ¶
type ErrorType string
ErrorType represents the type of vector database error
const ( ErrorTypeConnection ErrorType = "connection" ErrorTypeAuthentication ErrorType = "authentication" ErrorTypeNotFound ErrorType = "not_found" ErrorTypeAlreadyExists ErrorType = "already_exists" ErrorTypeInvalidConfig ErrorType = "invalid_config" ErrorTypeInvalidSchema ErrorType = "invalid_schema" ErrorTypeInvalidQuery ErrorType = "invalid_query" ErrorTypeTimeout ErrorType = "timeout" ErrorTypeQuotaExceeded ErrorType = "quota_exceeded" ErrorTypeInternal ErrorType = "internal" ErrorTypeUnsupported ErrorType = "unsupported" )
type FieldDefinition ¶
FieldDefinition represents a field in a collection schema
type QueryOperations ¶
type QueryOperations interface {
// SearchSemantic performs semantic search using vector embeddings
SearchSemantic(ctx context.Context, collectionName, query string, options *QueryOptions) ([]*QueryResult, error)
// SearchBM25 performs keyword-based search using BM25
SearchBM25(ctx context.Context, collectionName, query string, options *QueryOptions) ([]*QueryResult, error)
// SearchHybrid performs hybrid search combining vector and keyword search
SearchHybrid(ctx context.Context, collectionName, query string, options *QueryOptions) ([]*QueryResult, error)
// SearchByMetadata searches documents by metadata fields
SearchByMetadata(ctx context.Context, collectionName string, metadata map[string]interface{}, options *QueryOptions) ([]*QueryResult, error)
}
QueryOperations defines search and query operations
type QueryOptions ¶
type QueryOptions struct {
TopK int `json:"top_k"`
Distance float64 `json:"distance"`
SearchMetadata bool `json:"search_metadata"`
NoTruncate bool `json:"no_truncate"`
UseBM25 bool `json:"use_bm25"`
}
QueryOptions represents options for querying the vector database
type QueryResult ¶
QueryResult represents a search result with score
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds all registered client factories
func (*Registry) CreateClient ¶
func (r *Registry) CreateClient(config *Config) (VectorDBClient, error)
CreateClient creates a client using the appropriate factory
func (*Registry) GetSupportedTypes ¶
func (r *Registry) GetSupportedTypes() []VectorDBType
GetSupportedTypes returns all supported database types
func (*Registry) IsSupported ¶
func (r *Registry) IsSupported(dbType VectorDBType) bool
IsSupported checks if a database type is supported
func (*Registry) Register ¶
func (r *Registry) Register(dbType VectorDBType, factory ClientFactory)
Register registers a client factory for a specific database type
type SchemaOperations ¶
type SchemaOperations interface {
// GetSchema retrieves the schema for a collection
GetSchema(ctx context.Context, collectionName string) (*CollectionSchema, error)
// UpdateSchema updates the schema for a collection
UpdateSchema(ctx context.Context, collectionName string, schema *CollectionSchema) error
// GetDefaultSchema returns a default schema for the given type
GetDefaultSchema(schemaType SchemaType, collectionName string) *CollectionSchema
// ValidateSchema validates a schema definition
ValidateSchema(schema *CollectionSchema) error
}
SchemaOperations defines schema management operations
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 VectorDBClient ¶
type VectorDBClient interface {
// Health checks the health of the vector database instance
Health(ctx context.Context) error
// Collection operations
CollectionOperations
// Document operations
DocumentOperations
// Query operations
QueryOperations
// Schema operations
SchemaOperations
}
VectorDBClient defines the interface that all vector database implementations must satisfy
func CreateClient ¶
func CreateClient(config *Config) (VectorDBClient, error)
CreateClient creates a client using the global registry
func CreateClientFromVectorDBConfig ¶
func CreateClientFromVectorDBConfig(cfg *config.VectorDBConfig) (VectorDBClient, error)
CreateClientFromVectorDBConfig creates a client from the legacy VectorDBConfig
type VectorDBError ¶
type VectorDBError struct {
Type ErrorType
Message string
Cause error
Collection string
Document string
Details map[string]interface{}
}
VectorDBError represents a vector database error with additional context
func ErrAlreadyExists ¶
func ErrAlreadyExists(resource, name string) *VectorDBError
ErrAlreadyExists creates an already exists error
func ErrAuthenticationFailed ¶
func ErrAuthenticationFailed(message string) *VectorDBError
ErrAuthenticationFailed creates an authentication error
func ErrConnectionFailed ¶
func ErrConnectionFailed(message string, cause error) *VectorDBError
ErrConnectionFailed creates a connection error
func ErrInternal ¶
func ErrInternal(message string, cause error) *VectorDBError
ErrInternal creates an internal error
func ErrInvalidConfig ¶
func ErrInvalidConfig(message string) *VectorDBError
ErrInvalidConfig creates an invalid configuration error
func ErrInvalidQuery ¶
func ErrInvalidQuery(message string) *VectorDBError
ErrInvalidQuery creates an invalid query error
func ErrInvalidSchema ¶
func ErrInvalidSchema(message string) *VectorDBError
ErrInvalidSchema creates an invalid schema error
func ErrNotFound ¶
func ErrNotFound(resource, name string) *VectorDBError
ErrNotFound creates a not found error
func ErrQuotaExceeded ¶
func ErrQuotaExceeded(message string) *VectorDBError
ErrQuotaExceeded creates a quota exceeded error
func ErrTimeout ¶
func ErrTimeout(operation string) *VectorDBError
ErrTimeout creates a timeout error
func ErrUnsupported ¶
func ErrUnsupported(operation string) *VectorDBError
ErrUnsupported creates an unsupported operation error
func NewError ¶
func NewError(errorType ErrorType, message string) *VectorDBError
NewError creates a new VectorDBError
func NewErrorWithCause ¶
func NewErrorWithCause(errorType ErrorType, message string, cause error) *VectorDBError
NewErrorWithCause creates a new VectorDBError with a cause
func (*VectorDBError) Error ¶
func (e *VectorDBError) Error() string
Error implements the error interface
func (*VectorDBError) Is ¶
func (e *VectorDBError) Is(target error) bool
Is checks if the error is of a specific type
func (*VectorDBError) Unwrap ¶
func (e *VectorDBError) Unwrap() error
Unwrap returns the underlying cause
func (*VectorDBError) WithCollection ¶
func (e *VectorDBError) WithCollection(collection string) *VectorDBError
WithCollection adds collection context to the error
func (*VectorDBError) WithDetail ¶
func (e *VectorDBError) WithDetail(key string, value interface{}) *VectorDBError
WithDetail adds a detail to the error
func (*VectorDBError) WithDocument ¶
func (e *VectorDBError) WithDocument(document string) *VectorDBError
WithDocument adds document context to the error
type VectorDBType ¶
type VectorDBType string
VectorDBType represents the type of vector database
const ( VectorDBTypeWeaviateCloud VectorDBType = "weaviate-cloud" VectorDBTypeWeaviateLocal VectorDBType = "weaviate-local" VectorDBTypeMock VectorDBType = "mock" VectorDBTypeSupabase VectorDBType = "supabase" // Legacy VectorDBTypeSupabaseCloud VectorDBType = "supabase-cloud" VectorDBTypeMilvusLocal VectorDBType = "milvus-local" VectorDBTypeMilvusCloud VectorDBType = "milvus-cloud" VectorDBTypeMongoDB VectorDBType = "mongodb" // Legacy VectorDBTypeMongoDBCloud VectorDBType = "mongodb-cloud" VectorDBTypeChromaLocal VectorDBType = "chroma-local" VectorDBTypeChromaCloud VectorDBType = "chroma-cloud" VectorDBTypeQdrantLocal VectorDBType = "qdrant-local" VectorDBTypeQdrantCloud VectorDBType = "qdrant-cloud" VectorDBTypeNeo4jLocal VectorDBType = "neo4j-local" VectorDBTypeNeo4jCloud VectorDBType = "neo4j-cloud" )
func GetSupportedTypes ¶
func GetSupportedTypes() []VectorDBType
GetSupportedTypes returns all supported database types from the global registry
Directories
¶
| Path | Synopsis |
|---|---|
|
Package chroma stub for unsupported platforms Chroma is only supported on macOS AMD64 and macOS ARM64 due to SDK limitations Linux support is blocked by libtokenizers CGO dependency in chroma-go v0.2.5
|
Package chroma stub for unsupported platforms Chroma is only supported on macOS AMD64 and macOS ARM64 due to SDK limitations Linux support is blocked by libtokenizers CGO dependency in chroma-go v0.2.5 |