Documentation
¶
Overview ¶
Download pre-built C libraries for the current platform:
This file exists to enable `go generate github.com/zvec-ai/zvec-go` for downloading pre-built zvec C-API libraries from GitHub Releases.
Usage:
go generate github.com/zvec-ai/zvec-go
This will run the download-libs command which: 1. Detects your current platform (darwin/arm64, linux/amd64, etc.) 2. Downloads the pre-built library archive from GitHub Releases 3. Extracts it to the ./lib directory
The version defaults to the latest published GitHub release (queried via the GitHub Releases API), or can be specified via the -version flag.
Package zvec provides Go bindings for the zvec vector database library.
Zvec is an open-source, in-process vector database — lightweight, lightning-fast, and designed to embed directly into applications. This Go SDK wraps the zvec C-API using cgo to provide idiomatic Go access to all zvec functionality.
Basic usage:
// Initialize the library
if err := zvec.Initialize(nil); err != nil {
log.Fatal(err)
}
defer zvec.Shutdown()
// Create a collection schema
schema := zvec.NewCollectionSchema("my_collection")
defer schema.Destroy()
// Add fields
idField := zvec.NewFieldSchema("id", zvec.DataTypeString, false, 0)
idField.SetIndexParams(zvec.NewInvertIndexParams(true, false))
schema.AddField(idField)
embeddingField := zvec.NewFieldSchema("embedding", zvec.DataTypeVectorFP32, false, 128)
hnswParams := zvec.NewHNSWIndexParams(zvec.MetricTypeCosine, 16, 200)
embeddingField.SetIndexParams(hnswParams)
schema.AddField(embeddingField)
// Create and open collection
collection, err := zvec.CreateAndOpen("./my_data", schema, nil)
if err != nil {
log.Fatal(err)
}
defer collection.Close()
Index ¶
- Variables
- func CheckVersion(major, minor, patch int) bool
- func ClearError()
- func FreeDocs(docs []*Doc)
- func GetDefaultJiebaDictDir() string
- func GetVersion() string
- func GetVersionMajor() int
- func GetVersionMinor() int
- func GetVersionPatch() int
- func Initialize(config *ConfigData) error
- func IsAlreadyExists(err error) bool
- func IsInitialized() bool
- func IsInvalidArgument(err error) bool
- func IsNotFound(err error) bool
- func SetDefaultJiebaDictDir(dir string)
- func Shutdown() error
- type Collection
- func (c *Collection) AddColumn(fieldSchema *FieldSchema, defaultExpr string) error
- func (c *Collection) AlterColumn(columnName, newName string, newSchema *FieldSchema) error
- func (c *Collection) Close() error
- func (c *Collection) CreateIndex(fieldName string, params *IndexParams) error
- func (c *Collection) Delete(pks []string) (*WriteResult, error)
- func (c *Collection) DeleteByFilter(filter string) error
- func (c *Collection) Destroy() error
- func (c *Collection) DropColumn(columnName string) error
- func (c *Collection) DropIndex(fieldName string) error
- func (c *Collection) Fetch(primaryKeys []string, opts *FetchOptions) ([]*Doc, error)
- func (c *Collection) Flush() error
- func (c *Collection) GetOptions() (*CollectionOptions, error)
- func (c *Collection) GetSchema() (*CollectionSchema, error)
- func (c *Collection) GetStats() (*CollectionStats, error)
- func (c *Collection) Insert(docs []*Doc) (*WriteResult, error)
- func (c *Collection) MultiQuery(query *MultiQuery) ([]*Doc, error)
- func (c *Collection) Optimize() error
- func (c *Collection) Query(query *SearchQuery) ([]*Doc, error)
- func (c *Collection) Update(docs []*Doc) (*WriteResult, error)
- func (c *Collection) Upsert(docs []*Doc) (*WriteResult, error)
- type CollectionOptions
- func (o *CollectionOptions) Destroy()
- func (o *CollectionOptions) GetEnableMmap() bool
- func (o *CollectionOptions) GetMaxBufferSize() uint64
- func (o *CollectionOptions) GetReadOnly() bool
- func (o *CollectionOptions) SetEnableMmap(enable bool) error
- func (o *CollectionOptions) SetMaxBufferSize(size uint64) error
- func (o *CollectionOptions) SetReadOnly(readOnly bool) error
- type CollectionSchema
- func (s *CollectionSchema) AddField(field *FieldSchema) error
- func (s *CollectionSchema) AddIndex(fieldName string, params *IndexParams) error
- func (s *CollectionSchema) Destroy()
- func (s *CollectionSchema) DropField(name string) error
- func (s *CollectionSchema) DropIndex(fieldName string) error
- func (s *CollectionSchema) GetField(name string) *FieldSchema
- func (s *CollectionSchema) GetMaxDocCountPerSegment() uint64
- func (s *CollectionSchema) GetName() string
- func (s *CollectionSchema) HasField(name string) bool
- func (s *CollectionSchema) HasIndex(fieldName string) bool
- func (s *CollectionSchema) SetMaxDocCountPerSegment(count uint64) error
- func (s *CollectionSchema) SetName(name string) error
- type CollectionStats
- type ConfigData
- func (c *ConfigData) Destroy()
- func (c *ConfigData) GetFTSBruteForceByKeysRatio() float32
- func (c *ConfigData) GetJiebaDictDir() string
- func (c *ConfigData) GetMemoryLimit() uint64
- func (c *ConfigData) GetOptimizeThreadCount() uint32
- func (c *ConfigData) GetQueryThreadCount() uint32
- func (c *ConfigData) SetConsoleLog(level LogLevel) error
- func (c *ConfigData) SetFTSBruteForceByKeysRatio(ratio float32) error
- func (c *ConfigData) SetFileLog(level LogLevel, dir, basename string, fileSizeMB, overdueDays uint32) error
- func (c *ConfigData) SetJiebaDictDir(dir string) error
- func (c *ConfigData) SetMemoryLimit(bytes uint64) error
- func (c *ConfigData) SetOptimizeThreadCount(count uint32) error
- func (c *ConfigData) SetQueryThreadCount(count uint32) error
- type DataType
- type DiskANNQueryParams
- func (p *DiskANNQueryParams) Destroy()
- func (p *DiskANNQueryParams) GetIsLinear() bool
- func (p *DiskANNQueryParams) GetIsUsingRefiner() bool
- func (p *DiskANNQueryParams) GetListSize() int
- func (p *DiskANNQueryParams) GetRadius() float32
- func (p *DiskANNQueryParams) SetIsLinear(isLinear bool) error
- func (p *DiskANNQueryParams) SetIsUsingRefiner(isUsingRefiner bool) error
- func (p *DiskANNQueryParams) SetListSize(listSize int) error
- func (p *DiskANNQueryParams) SetRadius(radius float32) error
- type Doc
- func (d *Doc) AddBinaryField(name string, data []byte) error
- func (d *Doc) AddBoolField(name string, value bool) error
- func (d *Doc) AddDoubleField(name string, value float64) error
- func (d *Doc) AddFloatField(name string, value float32) error
- func (d *Doc) AddInt32Field(name string, value int32) error
- func (d *Doc) AddInt64Field(name string, value int64) error
- func (d *Doc) AddStringField(name, value string) error
- func (d *Doc) AddUint32Field(name string, value uint32) error
- func (d *Doc) AddUint64Field(name string, value uint64) error
- func (d *Doc) AddVectorFP32Field(name string, vector []float32) error
- func (d *Doc) Clear()
- func (d *Doc) Destroy()
- func (d *Doc) GetBoolField(name string) (bool, error)
- func (d *Doc) GetDocID() uint64
- func (d *Doc) GetDoubleField(name string) (float64, error)
- func (d *Doc) GetFieldCount() int
- func (d *Doc) GetFieldNames() ([]string, error)
- func (d *Doc) GetFloatField(name string) (float32, error)
- func (d *Doc) GetInt32Field(name string) (int32, error)
- func (d *Doc) GetInt64Field(name string) (int64, error)
- func (d *Doc) GetOperator() DocOperator
- func (d *Doc) GetPK() string
- func (d *Doc) GetScore() float32
- func (d *Doc) GetStringField(name string) (string, error)
- func (d *Doc) GetUint32Field(name string) (uint32, error)
- func (d *Doc) GetUint64Field(name string) (uint64, error)
- func (d *Doc) GetVectorFP32Field(name string) ([]float32, error)
- func (d *Doc) HasField(name string) bool
- func (d *Doc) HasFieldValue(name string) bool
- func (d *Doc) IsEmpty() bool
- func (d *Doc) IsFieldNull(name string) bool
- func (d *Doc) RemoveField(name string) error
- func (d *Doc) SetDocID(docID uint64)
- func (d *Doc) SetFieldNull(name string) error
- func (d *Doc) SetOperator(op DocOperator)
- func (d *Doc) SetPK(pk string)
- func (d *Doc) SetScore(score float32)
- type DocOperator
- type Error
- type ErrorCode
- type FTS
- type FTSQueryParams
- type FetchOptions
- type FieldSchema
- func (f *FieldSchema) Destroy()
- func (f *FieldSchema) GetDataType() DataType
- func (f *FieldSchema) GetDimension() uint32
- func (f *FieldSchema) GetIndexType() IndexType
- func (f *FieldSchema) GetName() string
- func (f *FieldSchema) HasIndex() bool
- func (f *FieldSchema) IsDenseVector() bool
- func (f *FieldSchema) IsNullable() bool
- func (f *FieldSchema) IsSparseVector() bool
- func (f *FieldSchema) IsVectorField() bool
- func (f *FieldSchema) SetDataType(dataType DataType) error
- func (f *FieldSchema) SetDimension(dimension uint32) error
- func (f *FieldSchema) SetIndexParams(params *IndexParams) error
- func (f *FieldSchema) SetName(name string) error
- func (f *FieldSchema) SetNullable(nullable bool) error
- type FlatQueryParams
- type GroupBySearchQuery
- func (q *GroupBySearchQuery) Destroy()
- func (q *GroupBySearchQuery) SetDiskANNParams(params *DiskANNQueryParams) error
- func (q *GroupBySearchQuery) SetFieldName(name string) error
- func (q *GroupBySearchQuery) SetFilter(filter string) error
- func (q *GroupBySearchQuery) SetFlatParams(params *FlatQueryParams) error
- func (q *GroupBySearchQuery) SetGroupByFieldName(name string) error
- func (q *GroupBySearchQuery) SetGroupCount(count uint32) error
- func (q *GroupBySearchQuery) SetHNSWParams(params *HNSWQueryParams) error
- func (q *GroupBySearchQuery) SetIVFParams(params *IVFQueryParams) error
- func (q *GroupBySearchQuery) SetIncludeVector(include bool) error
- func (q *GroupBySearchQuery) SetOutputFields(fields []string) error
- func (q *GroupBySearchQuery) SetQueryVector(data []float32) error
- func (q *GroupBySearchQuery) SetTopkPerGroup(topk uint32) error
- type HNSWQueryParams
- type IVFQueryParams
- type IndexParams
- func NewDiskANNIndexParams(metric MetricType, maxDegree, listSize, pqChunkNum int) (*IndexParams, error)
- func NewFTSIndexParams(tokenizerName string, filters []string, extraParams string) (*IndexParams, error)
- func NewFlatIndexParams(metric MetricType) (*IndexParams, error)
- func NewHNSWIndexParams(metric MetricType, m, efConstruction int) (*IndexParams, error)
- func NewIVFIndexParams(metric MetricType, nList, nIters int, useSoar bool) (*IndexParams, error)
- func NewIndexParams(indexType IndexType) *IndexParams
- func NewInvertIndexParams(enableRangeOpt, enableWildcard bool) (*IndexParams, error)
- func (p *IndexParams) Destroy()
- func (p *IndexParams) GetDiskANNListSize() int
- func (p *IndexParams) GetDiskANNMaxDegree() int
- func (p *IndexParams) GetDiskANNPQChunkNum() int
- func (p *IndexParams) GetFTSParams() (tokenizerName string, filters []string, extraParams string, err error)
- func (p *IndexParams) GetHNSWEfConstruction() int
- func (p *IndexParams) GetHNSWM() int
- func (p *IndexParams) GetMetricType() MetricType
- func (p *IndexParams) GetQuantizeType() QuantizeType
- func (p *IndexParams) GetType() IndexType
- func (p *IndexParams) SetDiskANNParams(maxDegree, listSize, pqChunkNum int) error
- func (p *IndexParams) SetFTSParams(tokenizerName string, filters []string, extraParams string) error
- func (p *IndexParams) SetHNSWParams(m, efConstruction int) error
- func (p *IndexParams) SetIVFParams(nList, nIters int, useSoar bool) error
- func (p *IndexParams) SetInvertParams(enableRangeOpt, enableWildcard bool) error
- func (p *IndexParams) SetMetricType(metric MetricType) error
- func (p *IndexParams) SetQuantizeType(quantize QuantizeType) error
- type IndexType
- type LogLevel
- type MetricType
- type MultiQuery
- func (q *MultiQuery) AddSubQuery(sub *SubQuery) error
- func (q *MultiQuery) Destroy()
- func (q *MultiQuery) GetFilter() string
- func (q *MultiQuery) GetIncludeVector() bool
- func (q *MultiQuery) GetSubQueryCount() int
- func (q *MultiQuery) GetTopK() int
- func (q *MultiQuery) SetFilter(filter string) error
- func (q *MultiQuery) SetIncludeVector(include bool) error
- func (q *MultiQuery) SetOutputFields(fields []string) error
- func (q *MultiQuery) SetRerankRRF(rankConstant int) error
- func (q *MultiQuery) SetRerankWeighted(weights []float64) error
- func (q *MultiQuery) SetTopK(topk int) error
- type QuantizeType
- type SearchQuery
- func (q *SearchQuery) Destroy()
- func (q *SearchQuery) GetFTS() *FTS
- func (q *SearchQuery) GetFieldName() string
- func (q *SearchQuery) GetFilter() string
- func (q *SearchQuery) GetIncludeDocID() bool
- func (q *SearchQuery) GetIncludeVector() bool
- func (q *SearchQuery) GetTopK() int
- func (q *SearchQuery) SetDiskANNParams(params *DiskANNQueryParams) error
- func (q *SearchQuery) SetFTS(fts *FTS) error
- func (q *SearchQuery) SetFTSParams(params *FTSQueryParams) error
- func (q *SearchQuery) SetFieldName(name string) error
- func (q *SearchQuery) SetFilter(filter string) error
- func (q *SearchQuery) SetFlatParams(params *FlatQueryParams) error
- func (q *SearchQuery) SetHNSWParams(params *HNSWQueryParams) error
- func (q *SearchQuery) SetIVFParams(params *IVFQueryParams) error
- func (q *SearchQuery) SetIncludeDocID(include bool) error
- func (q *SearchQuery) SetIncludeVector(include bool) error
- func (q *SearchQuery) SetOutputFields(fields []string) error
- func (q *SearchQuery) SetQueryVector(data []float32) error
- func (q *SearchQuery) SetTopK(topk int) error
- type SubQuery
- func (q *SubQuery) Destroy()
- func (q *SubQuery) GetFieldName() string
- func (q *SubQuery) GetNumCandidates() int
- func (q *SubQuery) SetDiskANNParams(params *DiskANNQueryParams) error
- func (q *SubQuery) SetFTS(fts *FTS) error
- func (q *SubQuery) SetFTSParams(params *FTSQueryParams) error
- func (q *SubQuery) SetFieldName(name string) error
- func (q *SubQuery) SetFlatParams(params *FlatQueryParams) error
- func (q *SubQuery) SetHNSWParams(params *HNSWQueryParams) error
- func (q *SubQuery) SetIVFParams(params *IVFQueryParams) error
- func (q *SubQuery) SetNumCandidates(n int) error
- func (q *SubQuery) SetQueryVector(data []float32) error
- func (q *SubQuery) SetSparseVector(indices []uint32, values []float32) error
- type WriteResult
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = &Error{Code: NotFound, Message: "resource not found"} ErrAlreadyExists = &Error{Code: AlreadyExists, Message: "resource already exists"} ErrInvalidArgument = &Error{Code: InvalidArgument, Message: "invalid argument"} ErrPermissionDenied = &Error{Code: PermissionDenied, Message: "permission denied"} ErrFailedPrecondition = &Error{Code: FailedPrecondition, Message: "failed precondition"} ErrResourceExhausted = &Error{Code: ResourceExhausted, Message: "resource exhausted"} ErrInternalError = &Error{Code: InternalError, Message: "internal error"} ErrNotSupported = &Error{Code: NotSupported, Message: "not supported"} ErrUnknown = &Error{Code: Unknown, Message: "unknown error"} )
Sentinel errors for common error codes.
Functions ¶
func CheckVersion ¶
CheckVersion checks if the current library version meets the minimum requirements.
func FreeDocs ¶
func FreeDocs(docs []*Doc)
FreeDocs is a convenience function to destroy multiple documents at once.
func GetDefaultJiebaDictDir ¶ added in v0.5.0
func GetDefaultJiebaDictDir() string
GetDefaultJiebaDictDir returns the process-wide default jieba dictionary directory.
func Initialize ¶
func Initialize(config *ConfigData) error
Initialize initializes the zvec library with optional configuration. Pass nil to use default configuration. Must be called before any other zvec operations.
func IsAlreadyExists ¶
IsAlreadyExists checks if the error is an already exists error.
func IsInitialized ¶
func IsInitialized() bool
IsInitialized checks if the library has been initialized.
func IsInvalidArgument ¶
IsInvalidArgument checks if the error is an invalid argument error.
func IsNotFound ¶
IsNotFound checks if the error is a not found error.
func SetDefaultJiebaDictDir ¶ added in v0.5.0
func SetDefaultJiebaDictDir(dir string)
SetDefaultJiebaDictDir sets the process-wide default jieba dictionary directory. Thread-safe. Pass empty string to clear.
Types ¶
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
Collection represents a zvec collection.
func CreateAndOpen ¶
func CreateAndOpen(path string, schema *CollectionSchema, options *CollectionOptions) (*Collection, error)
CreateAndOpen creates a new collection and opens it. The caller is responsible for calling Close() when done.
func Open ¶
func Open(path string, options *CollectionOptions) (*Collection, error)
Open opens an existing collection. The caller is responsible for calling Close() when done.
func (*Collection) AddColumn ¶
func (c *Collection) AddColumn(fieldSchema *FieldSchema, defaultExpr string) error
AddColumn adds a new column to the collection.
func (*Collection) AlterColumn ¶
func (c *Collection) AlterColumn(columnName, newName string, newSchema *FieldSchema) error
AlterColumn alters a column in the collection. Pass empty string for newName to skip renaming. Pass nil for newSchema to skip schema modification.
func (*Collection) Close ¶
func (c *Collection) Close() error
Close closes the collection and releases the handle. The collection data on disk is preserved and can be reopened with Open().
func (*Collection) CreateIndex ¶
func (c *Collection) CreateIndex(fieldName string, params *IndexParams) error
CreateIndex creates an index for a collection field.
func (*Collection) Delete ¶
func (c *Collection) Delete(pks []string) (*WriteResult, error)
Delete deletes documents by primary keys.
func (*Collection) DeleteByFilter ¶
func (c *Collection) DeleteByFilter(filter string) error
DeleteByFilter deletes documents matching the filter expression.
func (*Collection) Destroy ¶
func (c *Collection) Destroy() error
Destroy destroys the collection data on disk and releases the handle. After calling Destroy, the collection data is permanently deleted. Note: zvec_collection_destroy deletes data but does not free the handle; zvec_collection_close frees the handle (deletes the shared_ptr).
func (*Collection) DropColumn ¶
func (c *Collection) DropColumn(columnName string) error
DropColumn drops a column from the collection.
func (*Collection) DropIndex ¶
func (c *Collection) DropIndex(fieldName string) error
DropIndex drops an index from a collection field.
func (*Collection) Fetch ¶
func (c *Collection) Fetch(primaryKeys []string, opts *FetchOptions) ([]*Doc, error)
Fetch retrieves documents by primary keys. Pass nil for opts to use defaults (all fields, no vectors). The caller is responsible for calling Destroy() on each returned Doc, or using FreeDocs() to free all at once.
func (*Collection) Flush ¶
func (c *Collection) Flush() error
Flush flushes collection data to disk.
func (*Collection) GetOptions ¶
func (c *Collection) GetOptions() (*CollectionOptions, error)
GetOptions returns the collection options. The caller is responsible for calling Destroy() on the returned options.
func (*Collection) GetSchema ¶
func (c *Collection) GetSchema() (*CollectionSchema, error)
GetSchema returns the collection schema. The caller is responsible for calling Destroy() on the returned schema.
func (*Collection) GetStats ¶
func (c *Collection) GetStats() (*CollectionStats, error)
GetStats returns collection statistics.
func (*Collection) Insert ¶
func (c *Collection) Insert(docs []*Doc) (*WriteResult, error)
Insert inserts documents into the collection.
func (*Collection) MultiQuery ¶ added in v0.5.0
func (c *Collection) MultiQuery(query *MultiQuery) ([]*Doc, error)
MultiQuery performs a multi-query search combining multiple sub-queries. The caller is responsible for calling Destroy() on each returned Doc, or using FreeDocs() to free all at once.
func (*Collection) Optimize ¶
func (c *Collection) Optimize() error
Optimize optimizes the collection (rebuild indexes, merge segments, etc.).
func (*Collection) Query ¶
func (c *Collection) Query(query *SearchQuery) ([]*Doc, error)
Query performs a vector similarity search. The caller is responsible for calling Destroy() on each returned Doc, or using FreeDocs() to free all at once.
func (*Collection) Update ¶
func (c *Collection) Update(docs []*Doc) (*WriteResult, error)
Update updates documents in the collection.
func (*Collection) Upsert ¶
func (c *Collection) Upsert(docs []*Doc) (*WriteResult, error)
Upsert inserts or updates documents in the collection.
type CollectionOptions ¶
type CollectionOptions struct {
// contains filtered or unexported fields
}
CollectionOptions represents options for creating or opening a collection.
func NewCollectionOptions ¶
func NewCollectionOptions() *CollectionOptions
NewCollectionOptions creates a new collection options instance.
func (*CollectionOptions) Destroy ¶
func (o *CollectionOptions) Destroy()
Destroy releases the collection options resources.
func (*CollectionOptions) GetEnableMmap ¶
func (o *CollectionOptions) GetEnableMmap() bool
GetEnableMmap returns whether memory mapping is enabled.
func (*CollectionOptions) GetMaxBufferSize ¶
func (o *CollectionOptions) GetMaxBufferSize() uint64
GetMaxBufferSize returns the maximum buffer size in bytes.
func (*CollectionOptions) GetReadOnly ¶
func (o *CollectionOptions) GetReadOnly() bool
GetReadOnly returns whether the collection is read-only.
func (*CollectionOptions) SetEnableMmap ¶
func (o *CollectionOptions) SetEnableMmap(enable bool) error
SetEnableMmap sets whether to enable memory mapping.
func (*CollectionOptions) SetMaxBufferSize ¶
func (o *CollectionOptions) SetMaxBufferSize(size uint64) error
SetMaxBufferSize sets the maximum buffer size in bytes.
func (*CollectionOptions) SetReadOnly ¶
func (o *CollectionOptions) SetReadOnly(readOnly bool) error
SetReadOnly sets whether the collection is read-only.
type CollectionSchema ¶
type CollectionSchema struct {
// contains filtered or unexported fields
}
CollectionSchema wraps zvec_collection_schema_t (opaque pointer).
func NewCollectionSchema ¶
func NewCollectionSchema(name string) *CollectionSchema
NewCollectionSchema creates a new collection schema with the specified name.
func (*CollectionSchema) AddField ¶
func (s *CollectionSchema) AddField(field *FieldSchema) error
AddField adds a field to the collection schema.
func (*CollectionSchema) AddIndex ¶
func (s *CollectionSchema) AddIndex(fieldName string, params *IndexParams) error
AddIndex adds an index to a field.
func (*CollectionSchema) Destroy ¶
func (s *CollectionSchema) Destroy()
Destroy releases the collection schema resources.
func (*CollectionSchema) DropField ¶
func (s *CollectionSchema) DropField(name string) error
DropField drops a field from the collection schema.
func (*CollectionSchema) DropIndex ¶
func (s *CollectionSchema) DropIndex(fieldName string) error
DropIndex drops an index from a field.
func (*CollectionSchema) GetField ¶
func (s *CollectionSchema) GetField(name string) *FieldSchema
GetField returns the field with the specified name (non-owning).
func (*CollectionSchema) GetMaxDocCountPerSegment ¶
func (s *CollectionSchema) GetMaxDocCountPerSegment() uint64
GetMaxDocCountPerSegment returns the maximum document count per segment.
func (*CollectionSchema) GetName ¶
func (s *CollectionSchema) GetName() string
GetName returns the collection name.
func (*CollectionSchema) HasField ¶
func (s *CollectionSchema) HasField(name string) bool
HasField returns whether the collection has a field with the specified name.
func (*CollectionSchema) HasIndex ¶
func (s *CollectionSchema) HasIndex(fieldName string) bool
HasIndex returns whether a field has an index.
func (*CollectionSchema) SetMaxDocCountPerSegment ¶
func (s *CollectionSchema) SetMaxDocCountPerSegment(count uint64) error
SetMaxDocCountPerSegment sets the maximum document count per segment.
func (*CollectionSchema) SetName ¶
func (s *CollectionSchema) SetName(name string) error
SetName sets the collection name.
type CollectionStats ¶
type CollectionStats struct {
DocCount uint64
IndexCount int
IndexNames []string
IndexCompleteness []float32
}
CollectionStats holds statistics about a collection.
type ConfigData ¶
type ConfigData struct {
// contains filtered or unexported fields
}
ConfigData represents the global configuration for the zvec library.
func NewConfigData ¶
func NewConfigData() *ConfigData
NewConfigData creates a new configuration data instance.
func (*ConfigData) Destroy ¶
func (c *ConfigData) Destroy()
Destroy releases the configuration data resources.
func (*ConfigData) GetFTSBruteForceByKeysRatio ¶ added in v0.5.0
func (c *ConfigData) GetFTSBruteForceByKeysRatio() float32
GetFTSBruteForceByKeysRatio returns the FTS brute force by keys ratio.
func (*ConfigData) GetJiebaDictDir ¶ added in v0.5.0
func (c *ConfigData) GetJiebaDictDir() string
GetJiebaDictDir returns the jieba dictionary directory.
func (*ConfigData) GetMemoryLimit ¶
func (c *ConfigData) GetMemoryLimit() uint64
GetMemoryLimit returns the memory limit in bytes.
func (*ConfigData) GetOptimizeThreadCount ¶
func (c *ConfigData) GetOptimizeThreadCount() uint32
GetOptimizeThreadCount returns the number of optimize threads.
func (*ConfigData) GetQueryThreadCount ¶
func (c *ConfigData) GetQueryThreadCount() uint32
GetQueryThreadCount returns the number of query threads.
func (*ConfigData) SetConsoleLog ¶
func (c *ConfigData) SetConsoleLog(level LogLevel) error
SetConsoleLog configures console logging with the specified level.
func (*ConfigData) SetFTSBruteForceByKeysRatio ¶ added in v0.5.0
func (c *ConfigData) SetFTSBruteForceByKeysRatio(ratio float32) error
SetFTSBruteForceByKeysRatio sets the FTS brute force by keys ratio.
func (*ConfigData) SetFileLog ¶
func (c *ConfigData) SetFileLog(level LogLevel, dir, basename string, fileSizeMB, overdueDays uint32) error
SetFileLog configures file logging.
func (*ConfigData) SetJiebaDictDir ¶ added in v0.5.0
func (c *ConfigData) SetJiebaDictDir(dir string) error
SetJiebaDictDir sets the jieba dictionary directory.
func (*ConfigData) SetMemoryLimit ¶
func (c *ConfigData) SetMemoryLimit(bytes uint64) error
SetMemoryLimit sets the memory limit in bytes.
func (*ConfigData) SetOptimizeThreadCount ¶
func (c *ConfigData) SetOptimizeThreadCount(count uint32) error
SetOptimizeThreadCount sets the number of optimize threads.
func (*ConfigData) SetQueryThreadCount ¶
func (c *ConfigData) SetQueryThreadCount(count uint32) error
SetQueryThreadCount sets the number of query threads.
type DataType ¶
type DataType uint32
DataType represents the data type of a field.
const ( DataTypeUndefined DataType = 0 DataTypeBinary DataType = 1 DataTypeString DataType = 2 DataTypeBool DataType = 3 DataTypeInt32 DataType = 4 DataTypeInt64 DataType = 5 DataTypeUint32 DataType = 6 DataTypeUint64 DataType = 7 DataTypeFloat DataType = 8 DataTypeDouble DataType = 9 DataTypeVectorBinary32 DataType = 20 DataTypeVectorBinary64 DataType = 21 DataTypeVectorFP16 DataType = 22 DataTypeVectorFP32 DataType = 23 DataTypeVectorFP64 DataType = 24 DataTypeVectorInt4 DataType = 25 DataTypeVectorInt8 DataType = 26 DataTypeVectorInt16 DataType = 27 DataTypeSparseVectorFP16 DataType = 30 DataTypeSparseVectorFP32 DataType = 31 DataTypeArrayBinary DataType = 40 DataTypeArrayString DataType = 41 DataTypeArrayBool DataType = 42 DataTypeArrayInt32 DataType = 43 DataTypeArrayInt64 DataType = 44 DataTypeArrayUint32 DataType = 45 DataTypeArrayUint64 DataType = 46 DataTypeArrayFloat DataType = 47 DataTypeArrayDouble DataType = 48 )
type DiskANNQueryParams ¶ added in v0.6.0
type DiskANNQueryParams struct {
// contains filtered or unexported fields
}
DiskANNQueryParams represents query parameters for DiskANN index.
func NewDiskANNQueryParams ¶ added in v0.6.0
func NewDiskANNQueryParams(listSize int) *DiskANNQueryParams
NewDiskANNQueryParams creates a new DiskANN query parameters instance.
func (*DiskANNQueryParams) Destroy ¶ added in v0.6.0
func (p *DiskANNQueryParams) Destroy()
Destroy releases the DiskANN query parameters resources.
func (*DiskANNQueryParams) GetIsLinear ¶ added in v0.6.0
func (p *DiskANNQueryParams) GetIsLinear() bool
GetIsLinear returns the linear search mode.
func (*DiskANNQueryParams) GetIsUsingRefiner ¶ added in v0.6.0
func (p *DiskANNQueryParams) GetIsUsingRefiner() bool
GetIsUsingRefiner returns whether to use refiner.
func (*DiskANNQueryParams) GetListSize ¶ added in v0.6.0
func (p *DiskANNQueryParams) GetListSize() int
GetListSize returns the search frontier size.
func (*DiskANNQueryParams) GetRadius ¶ added in v0.6.0
func (p *DiskANNQueryParams) GetRadius() float32
GetRadius returns the search radius.
func (*DiskANNQueryParams) SetIsLinear ¶ added in v0.6.0
func (p *DiskANNQueryParams) SetIsLinear(isLinear bool) error
SetIsLinear sets the linear search mode.
func (*DiskANNQueryParams) SetIsUsingRefiner ¶ added in v0.6.0
func (p *DiskANNQueryParams) SetIsUsingRefiner(isUsingRefiner bool) error
SetIsUsingRefiner sets whether to use refiner.
func (*DiskANNQueryParams) SetListSize ¶ added in v0.6.0
func (p *DiskANNQueryParams) SetListSize(listSize int) error
SetListSize sets the search frontier size.
func (*DiskANNQueryParams) SetRadius ¶ added in v0.6.0
func (p *DiskANNQueryParams) SetRadius(radius float32) error
SetRadius sets the search radius.
type Doc ¶
type Doc struct {
// contains filtered or unexported fields
}
Doc represents a document in the zvec vector database. It wraps the C zvec_doc_t handle.
func NewDoc ¶
func NewDoc() *Doc
NewDoc creates a new document with owned=true. The caller is responsible for calling Destroy() when done.
func (*Doc) AddBinaryField ¶
AddBinaryField adds a binary field to the document. The data must not be empty; use SetFieldNull for null values.
func (*Doc) AddBoolField ¶
AddBoolField adds a boolean field to the document.
func (*Doc) AddDoubleField ¶
AddDoubleField adds a float64 field to the document.
func (*Doc) AddFloatField ¶
AddFloatField adds a float32 field to the document.
func (*Doc) AddInt32Field ¶
AddInt32Field adds an int32 field to the document.
func (*Doc) AddInt64Field ¶
AddInt64Field adds an int64 field to the document.
func (*Doc) AddStringField ¶
AddStringField adds a string field to the document.
func (*Doc) AddUint32Field ¶
AddUint32Field adds a uint32 field to the document.
func (*Doc) AddUint64Field ¶
AddUint64Field adds a uint64 field to the document.
func (*Doc) AddVectorFP32Field ¶
AddVectorFP32Field adds a float32 vector field to the document.
func (*Doc) GetBoolField ¶
GetBoolField returns the boolean value of a field.
func (*Doc) GetDoubleField ¶
GetDoubleField returns the float64 value of a field.
func (*Doc) GetFieldCount ¶
GetFieldCount returns the number of fields in the document.
func (*Doc) GetFieldNames ¶
GetFieldNames returns a list of all field names in the document.
func (*Doc) GetFloatField ¶
GetFloatField returns the float32 value of a field.
func (*Doc) GetInt32Field ¶
GetInt32Field returns the int32 value of a field.
func (*Doc) GetInt64Field ¶
GetInt64Field returns the int64 value of a field.
func (*Doc) GetOperator ¶
func (d *Doc) GetOperator() DocOperator
GetOperator returns the document operator.
func (*Doc) GetStringField ¶
GetStringField returns the string value of a field.
func (*Doc) GetUint32Field ¶
GetUint32Field returns the uint32 value of a field.
func (*Doc) GetUint64Field ¶
GetUint64Field returns the uint64 value of a field.
func (*Doc) GetVectorFP32Field ¶
GetVectorFP32Field returns the float32 vector value of a field.
func (*Doc) HasFieldValue ¶
HasFieldValue returns true if the document has a field with the given name and a non-null value.
func (*Doc) IsFieldNull ¶
IsFieldNull returns true if the field with the given name is null.
func (*Doc) RemoveField ¶
RemoveField removes a field from the document.
func (*Doc) SetFieldNull ¶
SetFieldNull sets a field to null.
func (*Doc) SetOperator ¶
func (d *Doc) SetOperator(op DocOperator)
SetOperator sets the document operator.
type DocOperator ¶
type DocOperator int
DocOperator represents the document operation type.
const ( DocOpInsert DocOperator = 0 DocOpUpdate DocOperator = 1 DocOpUpsert DocOperator = 2 DocOpDelete DocOperator = 3 )
func (DocOperator) String ¶ added in v0.5.0
func (d DocOperator) String() string
type FTS ¶ added in v0.5.0
type FTS struct {
// contains filtered or unexported fields
}
FTS represents an FTS query payload (query string + match string).
func (*FTS) Destroy ¶ added in v0.5.0
func (f *FTS) Destroy()
Destroy releases the FTS query payload resources. Must not be called on FTS instances returned by SearchQuery.GetFTS().
func (*FTS) GetMatchString ¶ added in v0.5.0
GetMatchString returns the FTS match string.
func (*FTS) GetQueryString ¶ added in v0.5.0
GetQueryString returns the FTS query expression.
func (*FTS) SetMatchString ¶ added in v0.5.0
SetMatchString sets the FTS natural-language match string.
func (*FTS) SetQueryString ¶ added in v0.5.0
SetQueryString sets the FTS boolean / advanced query expression.
type FTSQueryParams ¶ added in v0.5.0
type FTSQueryParams struct {
// contains filtered or unexported fields
}
FTSQueryParams represents query parameters for FTS index.
func NewFTSQueryParams ¶ added in v0.5.0
func NewFTSQueryParams(defaultOperator string) *FTSQueryParams
NewFTSQueryParams creates a new FTS query parameters instance. defaultOperator is the boolean operator for adjacent bare terms ("OR" or "AND"). Pass empty string to use the built-in default.
func (*FTSQueryParams) Destroy ¶ added in v0.5.0
func (p *FTSQueryParams) Destroy()
Destroy releases the FTS query parameters resources.
func (*FTSQueryParams) GetDefaultOperator ¶ added in v0.5.0
func (p *FTSQueryParams) GetDefaultOperator() string
GetDefaultOperator returns the default boolean operator.
func (*FTSQueryParams) SetDefaultOperator ¶ added in v0.5.0
func (p *FTSQueryParams) SetDefaultOperator(op string) error
SetDefaultOperator sets the default boolean operator.
type FetchOptions ¶ added in v0.5.0
FetchOptions controls optional parameters for Fetch.
type FieldSchema ¶
type FieldSchema struct {
// contains filtered or unexported fields
}
FieldSchema wraps zvec_field_schema_t (opaque pointer).
func NewFieldSchema ¶
func NewFieldSchema(name string, dataType DataType, nullable bool, dimension uint32) *FieldSchema
NewFieldSchema creates a new field schema with the specified parameters.
func (*FieldSchema) Destroy ¶
func (f *FieldSchema) Destroy()
Destroy releases the field schema resources if owned.
func (*FieldSchema) GetDataType ¶
func (f *FieldSchema) GetDataType() DataType
GetDataType returns the field data type.
func (*FieldSchema) GetDimension ¶
func (f *FieldSchema) GetDimension() uint32
GetDimension returns the field dimension (for vector fields).
func (*FieldSchema) GetIndexType ¶
func (f *FieldSchema) GetIndexType() IndexType
GetIndexType returns the index type of the field.
func (*FieldSchema) GetName ¶
func (f *FieldSchema) GetName() string
GetName returns the field name.
func (*FieldSchema) HasIndex ¶
func (f *FieldSchema) HasIndex() bool
HasIndex returns whether the field has an index.
func (*FieldSchema) IsDenseVector ¶
func (f *FieldSchema) IsDenseVector() bool
IsDenseVector returns whether the field is a dense vector field.
func (*FieldSchema) IsNullable ¶
func (f *FieldSchema) IsNullable() bool
IsNullable returns whether the field is nullable.
func (*FieldSchema) IsSparseVector ¶
func (f *FieldSchema) IsSparseVector() bool
IsSparseVector returns whether the field is a sparse vector field.
func (*FieldSchema) IsVectorField ¶
func (f *FieldSchema) IsVectorField() bool
IsVectorField returns whether the field is a vector field (dense or sparse).
func (*FieldSchema) SetDataType ¶
func (f *FieldSchema) SetDataType(dataType DataType) error
SetDataType sets the field data type.
func (*FieldSchema) SetDimension ¶
func (f *FieldSchema) SetDimension(dimension uint32) error
SetDimension sets the field dimension (for vector fields).
func (*FieldSchema) SetIndexParams ¶
func (f *FieldSchema) SetIndexParams(params *IndexParams) error
SetIndexParams sets the index parameters for the field.
func (*FieldSchema) SetName ¶
func (f *FieldSchema) SetName(name string) error
SetName sets the field name.
func (*FieldSchema) SetNullable ¶
func (f *FieldSchema) SetNullable(nullable bool) error
SetNullable sets whether the field is nullable.
type FlatQueryParams ¶
type FlatQueryParams struct {
// contains filtered or unexported fields
}
FlatQueryParams represents query parameters for Flat index.
func NewFlatQueryParams ¶
func NewFlatQueryParams(isUsingRefiner bool, scaleFactor float32) *FlatQueryParams
NewFlatQueryParams creates a new Flat query parameters instance.
func (*FlatQueryParams) Destroy ¶
func (p *FlatQueryParams) Destroy()
Destroy releases the Flat query parameters resources.
type GroupBySearchQuery ¶ added in v0.5.0
type GroupBySearchQuery struct {
// contains filtered or unexported fields
}
GroupBySearchQuery represents a group-by vector query operation.
func NewGroupBySearchQuery ¶ added in v0.5.0
func NewGroupBySearchQuery() *GroupBySearchQuery
NewGroupBySearchQuery creates a new group-by vector query instance.
func (*GroupBySearchQuery) Destroy ¶ added in v0.5.0
func (q *GroupBySearchQuery) Destroy()
Destroy releases the group-by vector query resources.
func (*GroupBySearchQuery) SetDiskANNParams ¶ added in v0.6.0
func (q *GroupBySearchQuery) SetDiskANNParams(params *DiskANNQueryParams) error
SetDiskANNParams sets the DiskANN query parameters. Ownership of params is transferred to the query on success.
func (*GroupBySearchQuery) SetFieldName ¶ added in v0.5.0
func (q *GroupBySearchQuery) SetFieldName(name string) error
SetFieldName sets the field name for the vector query.
func (*GroupBySearchQuery) SetFilter ¶ added in v0.5.0
func (q *GroupBySearchQuery) SetFilter(filter string) error
SetFilter sets the filter expression for the query.
func (*GroupBySearchQuery) SetFlatParams ¶ added in v0.5.0
func (q *GroupBySearchQuery) SetFlatParams(params *FlatQueryParams) error
SetFlatParams sets the Flat query parameters.
func (*GroupBySearchQuery) SetGroupByFieldName ¶ added in v0.5.0
func (q *GroupBySearchQuery) SetGroupByFieldName(name string) error
SetGroupByFieldName sets the group-by field name.
func (*GroupBySearchQuery) SetGroupCount ¶ added in v0.5.0
func (q *GroupBySearchQuery) SetGroupCount(count uint32) error
SetGroupCount sets the group count parameter.
func (*GroupBySearchQuery) SetHNSWParams ¶ added in v0.5.0
func (q *GroupBySearchQuery) SetHNSWParams(params *HNSWQueryParams) error
SetHNSWParams sets the HNSW query parameters.
func (*GroupBySearchQuery) SetIVFParams ¶ added in v0.5.0
func (q *GroupBySearchQuery) SetIVFParams(params *IVFQueryParams) error
SetIVFParams sets the IVF query parameters.
func (*GroupBySearchQuery) SetIncludeVector ¶ added in v0.5.0
func (q *GroupBySearchQuery) SetIncludeVector(include bool) error
SetIncludeVector sets whether to include vector data in results.
func (*GroupBySearchQuery) SetOutputFields ¶ added in v0.5.0
func (q *GroupBySearchQuery) SetOutputFields(fields []string) error
SetOutputFields sets the output fields for the query.
func (*GroupBySearchQuery) SetQueryVector ¶ added in v0.5.0
func (q *GroupBySearchQuery) SetQueryVector(data []float32) error
SetQueryVector sets the query vector data.
func (*GroupBySearchQuery) SetTopkPerGroup ¶ added in v0.6.0
func (q *GroupBySearchQuery) SetTopkPerGroup(topk uint32) error
SetTopkPerGroup sets the maximum number of results per group.
type HNSWQueryParams ¶
type HNSWQueryParams struct {
// contains filtered or unexported fields
}
HNSWQueryParams represents query parameters for HNSW index.
func NewHNSWQueryParams ¶
func NewHNSWQueryParams(ef int, radius float32, isLinear, isUsingRefiner bool) *HNSWQueryParams
NewHNSWQueryParams creates a new HNSW query parameters instance.
func (*HNSWQueryParams) Destroy ¶
func (p *HNSWQueryParams) Destroy()
Destroy releases the HNSW query parameters resources.
func (*HNSWQueryParams) GetEf ¶
func (p *HNSWQueryParams) GetEf() int
GetEf returns the ef parameter.
func (*HNSWQueryParams) SetEf ¶
func (p *HNSWQueryParams) SetEf(ef int) error
SetEf sets the ef parameter for HNSW query.
type IVFQueryParams ¶
type IVFQueryParams struct {
// contains filtered or unexported fields
}
IVFQueryParams represents query parameters for IVF index.
func NewIVFQueryParams ¶
func NewIVFQueryParams(nprobe int, isUsingRefiner bool, scaleFactor float32) *IVFQueryParams
NewIVFQueryParams creates a new IVF query parameters instance.
func (*IVFQueryParams) Destroy ¶
func (p *IVFQueryParams) Destroy()
Destroy releases the IVF query parameters resources.
func (*IVFQueryParams) SetNprobe ¶
func (p *IVFQueryParams) SetNprobe(nprobe int) error
SetNprobe sets the nprobe parameter for IVF query.
type IndexParams ¶
type IndexParams struct {
// contains filtered or unexported fields
}
IndexParams wraps zvec_index_params_t (opaque pointer).
func NewDiskANNIndexParams ¶ added in v0.6.0
func NewDiskANNIndexParams(metric MetricType, maxDegree, listSize, pqChunkNum int) (*IndexParams, error)
NewDiskANNIndexParams creates DiskANN index parameters with the specified metric type.
func NewFTSIndexParams ¶ added in v0.5.0
func NewFTSIndexParams(tokenizerName string, filters []string, extraParams string) (*IndexParams, error)
NewFTSIndexParams creates FTS index parameters with the specified tokenizer and filters.
func NewFlatIndexParams ¶
func NewFlatIndexParams(metric MetricType) (*IndexParams, error)
NewFlatIndexParams creates Flat index parameters with the specified metric type.
func NewHNSWIndexParams ¶
func NewHNSWIndexParams(metric MetricType, m, efConstruction int) (*IndexParams, error)
NewHNSWIndexParams creates HNSW index parameters with the specified metric type and parameters.
func NewIVFIndexParams ¶
func NewIVFIndexParams(metric MetricType, nList, nIters int, useSoar bool) (*IndexParams, error)
NewIVFIndexParams creates IVF index parameters with the specified metric type and parameters.
func NewIndexParams ¶
func NewIndexParams(indexType IndexType) *IndexParams
NewIndexParams creates index parameters with the specified index type.
func NewInvertIndexParams ¶
func NewInvertIndexParams(enableRangeOpt, enableWildcard bool) (*IndexParams, error)
NewInvertIndexParams creates invert index parameters with the specified options.
func (*IndexParams) Destroy ¶
func (p *IndexParams) Destroy()
Destroy releases the index parameters resources.
func (*IndexParams) GetDiskANNListSize ¶ added in v0.6.0
func (p *IndexParams) GetDiskANNListSize() int
GetDiskANNListSize returns the DiskANN list_size parameter.
func (*IndexParams) GetDiskANNMaxDegree ¶ added in v0.6.0
func (p *IndexParams) GetDiskANNMaxDegree() int
GetDiskANNMaxDegree returns the DiskANN max_degree parameter.
func (*IndexParams) GetDiskANNPQChunkNum ¶ added in v0.6.0
func (p *IndexParams) GetDiskANNPQChunkNum() int
GetDiskANNPQChunkNum returns the DiskANN pq_chunk_num parameter.
func (*IndexParams) GetFTSParams ¶ added in v0.5.0
func (p *IndexParams) GetFTSParams() (tokenizerName string, filters []string, extraParams string, err error)
GetFTSParams returns FTS index parameters.
func (*IndexParams) GetHNSWEfConstruction ¶
func (p *IndexParams) GetHNSWEfConstruction() int
GetHNSWEfConstruction returns the HNSW ef_construction parameter.
func (*IndexParams) GetHNSWM ¶
func (p *IndexParams) GetHNSWM() int
GetHNSWM returns the HNSW m parameter.
func (*IndexParams) GetMetricType ¶
func (p *IndexParams) GetMetricType() MetricType
GetMetricType returns the metric type.
func (*IndexParams) GetQuantizeType ¶
func (p *IndexParams) GetQuantizeType() QuantizeType
GetQuantizeType returns the quantize type.
func (*IndexParams) GetType ¶
func (p *IndexParams) GetType() IndexType
GetType returns the index type.
func (*IndexParams) SetDiskANNParams ¶ added in v0.6.0
func (p *IndexParams) SetDiskANNParams(maxDegree, listSize, pqChunkNum int) error
SetDiskANNParams sets DiskANN specific parameters.
func (*IndexParams) SetFTSParams ¶ added in v0.5.0
func (p *IndexParams) SetFTSParams(tokenizerName string, filters []string, extraParams string) error
SetFTSParams sets FTS index specific parameters.
func (*IndexParams) SetHNSWParams ¶
func (p *IndexParams) SetHNSWParams(m, efConstruction int) error
SetHNSWParams sets HNSW specific parameters.
func (*IndexParams) SetIVFParams ¶
func (p *IndexParams) SetIVFParams(nList, nIters int, useSoar bool) error
SetIVFParams sets IVF specific parameters.
func (*IndexParams) SetInvertParams ¶
func (p *IndexParams) SetInvertParams(enableRangeOpt, enableWildcard bool) error
SetInvertParams sets invert index specific parameters.
func (*IndexParams) SetMetricType ¶
func (p *IndexParams) SetMetricType(metric MetricType) error
SetMetricType sets the metric type for vector indexes.
func (*IndexParams) SetQuantizeType ¶
func (p *IndexParams) SetQuantizeType(quantize QuantizeType) error
SetQuantizeType sets the quantize type for vector indexes.
type MetricType ¶
type MetricType uint32
MetricType represents the distance metric type.
const ( MetricTypeUndefined MetricType = 0 MetricTypeL2 MetricType = 1 MetricTypeIP MetricType = 2 MetricTypeCosine MetricType = 3 MetricTypeMIPSL2 MetricType = 4 )
func (MetricType) String ¶ added in v0.5.0
func (m MetricType) String() string
type MultiQuery ¶ added in v0.5.0
type MultiQuery struct {
// contains filtered or unexported fields
}
MultiQuery represents a multi-query operation combining multiple sub-queries.
func NewMultiQuery ¶ added in v0.5.0
func NewMultiQuery() *MultiQuery
NewMultiQuery creates a new multi-query instance.
func (*MultiQuery) AddSubQuery ¶ added in v0.5.0
func (q *MultiQuery) AddSubQuery(sub *SubQuery) error
AddSubQuery adds a sub-query to the multi-query. The sub-query is copied; the caller retains ownership.
func (*MultiQuery) Destroy ¶ added in v0.5.0
func (q *MultiQuery) Destroy()
Destroy releases the multi-query resources.
func (*MultiQuery) GetFilter ¶ added in v0.5.0
func (q *MultiQuery) GetFilter() string
GetFilter returns the filter expression.
func (*MultiQuery) GetIncludeVector ¶ added in v0.5.0
func (q *MultiQuery) GetIncludeVector() bool
GetIncludeVector returns whether vector data is included in results.
func (*MultiQuery) GetSubQueryCount ¶ added in v0.5.0
func (q *MultiQuery) GetSubQueryCount() int
GetSubQueryCount returns the number of sub-queries.
func (*MultiQuery) GetTopK ¶ added in v0.5.0
func (q *MultiQuery) GetTopK() int
GetTopK returns the top-k parameter.
func (*MultiQuery) SetFilter ¶ added in v0.5.0
func (q *MultiQuery) SetFilter(filter string) error
SetFilter sets the filter expression for the multi-query.
func (*MultiQuery) SetIncludeVector ¶ added in v0.5.0
func (q *MultiQuery) SetIncludeVector(include bool) error
SetIncludeVector sets whether to include vector data in results.
func (*MultiQuery) SetOutputFields ¶ added in v0.5.0
func (q *MultiQuery) SetOutputFields(fields []string) error
SetOutputFields sets the output fields for the multi-query.
func (*MultiQuery) SetRerankRRF ¶ added in v0.5.0
func (q *MultiQuery) SetRerankRRF(rankConstant int) error
SetRerankRRF sets the RRF (Reciprocal Rank Fusion) rerank strategy.
func (*MultiQuery) SetRerankWeighted ¶ added in v0.5.0
func (q *MultiQuery) SetRerankWeighted(weights []float64) error
SetRerankWeighted sets the Weighted rerank strategy with the given per-sub-query weights.
func (*MultiQuery) SetTopK ¶ added in v0.5.0
func (q *MultiQuery) SetTopK(topk int) error
SetTopK sets the top-k parameter for the multi-query.
type QuantizeType ¶
type QuantizeType uint32
QuantizeType represents the quantization type.
const ( QuantizeTypeUndefined QuantizeType = 0 QuantizeTypeFP16 QuantizeType = 1 QuantizeTypeInt8 QuantizeType = 2 QuantizeTypeInt4 QuantizeType = 3 )
func (QuantizeType) String ¶ added in v0.5.0
func (q QuantizeType) String() string
type SearchQuery ¶ added in v0.5.0
type SearchQuery struct {
// contains filtered or unexported fields
}
SearchQuery represents a vector query operation.
func NewSearchQuery ¶ added in v0.5.0
func NewSearchQuery() *SearchQuery
NewSearchQuery creates a new vector query instance.
func (*SearchQuery) Destroy ¶ added in v0.5.0
func (q *SearchQuery) Destroy()
Destroy releases the vector query resources.
func (*SearchQuery) GetFTS ¶ added in v0.5.0
func (q *SearchQuery) GetFTS() *FTS
GetFTS returns the FTS query payload attached to this query. Returns nil if no FTS payload is attached. The returned FTS is owned by the query and must NOT be destroyed by the caller.
func (*SearchQuery) GetFieldName ¶ added in v0.5.0
func (q *SearchQuery) GetFieldName() string
GetFieldName returns the field name.
func (*SearchQuery) GetFilter ¶ added in v0.5.0
func (q *SearchQuery) GetFilter() string
GetFilter returns the filter expression.
func (*SearchQuery) GetIncludeDocID ¶ added in v0.5.0
func (q *SearchQuery) GetIncludeDocID() bool
GetIncludeDocID returns whether document ID is included in results.
func (*SearchQuery) GetIncludeVector ¶ added in v0.5.0
func (q *SearchQuery) GetIncludeVector() bool
GetIncludeVector returns whether vector data is included in results.
func (*SearchQuery) GetTopK ¶ added in v0.5.0
func (q *SearchQuery) GetTopK() int
GetTopK returns the top-k parameter.
func (*SearchQuery) SetDiskANNParams ¶ added in v0.6.0
func (q *SearchQuery) SetDiskANNParams(params *DiskANNQueryParams) error
SetDiskANNParams sets the DiskANN query parameters. Ownership of params is transferred to the query on success.
func (*SearchQuery) SetFTS ¶ added in v0.5.0
func (q *SearchQuery) SetFTS(fts *FTS) error
SetFTS sets the FTS query payload on this query. The payload is copied; the caller retains ownership of fts.
func (*SearchQuery) SetFTSParams ¶ added in v0.5.0
func (q *SearchQuery) SetFTSParams(params *FTSQueryParams) error
SetFTSParams sets the FTS query parameters. Ownership of params is transferred to the query on success.
func (*SearchQuery) SetFieldName ¶ added in v0.5.0
func (q *SearchQuery) SetFieldName(name string) error
SetFieldName sets the field name for the vector query.
func (*SearchQuery) SetFilter ¶ added in v0.5.0
func (q *SearchQuery) SetFilter(filter string) error
SetFilter sets the filter expression for the query.
func (*SearchQuery) SetFlatParams ¶ added in v0.5.0
func (q *SearchQuery) SetFlatParams(params *FlatQueryParams) error
SetFlatParams sets the Flat query parameters.
func (*SearchQuery) SetHNSWParams ¶ added in v0.5.0
func (q *SearchQuery) SetHNSWParams(params *HNSWQueryParams) error
SetHNSWParams sets the HNSW query parameters. Note: ownership of params is transferred to the query.
func (*SearchQuery) SetIVFParams ¶ added in v0.5.0
func (q *SearchQuery) SetIVFParams(params *IVFQueryParams) error
SetIVFParams sets the IVF query parameters.
func (*SearchQuery) SetIncludeDocID ¶ added in v0.5.0
func (q *SearchQuery) SetIncludeDocID(include bool) error
SetIncludeDocID sets whether to include document ID in results.
func (*SearchQuery) SetIncludeVector ¶ added in v0.5.0
func (q *SearchQuery) SetIncludeVector(include bool) error
SetIncludeVector sets whether to include vector data in results.
func (*SearchQuery) SetOutputFields ¶ added in v0.5.0
func (q *SearchQuery) SetOutputFields(fields []string) error
SetOutputFields sets the output fields for the query.
func (*SearchQuery) SetQueryVector ¶ added in v0.5.0
func (q *SearchQuery) SetQueryVector(data []float32) error
SetQueryVector sets the query vector data.
func (*SearchQuery) SetTopK ¶ added in v0.5.0
func (q *SearchQuery) SetTopK(topk int) error
SetTopK sets the top-k parameter for the query.
type SubQuery ¶ added in v0.5.0
type SubQuery struct {
// contains filtered or unexported fields
}
SubQuery represents a sub-query within a multi-query.
func NewSubQuery ¶ added in v0.5.0
func NewSubQuery() *SubQuery
NewSubQuery creates a new sub-query instance.
func (*SubQuery) Destroy ¶ added in v0.5.0
func (q *SubQuery) Destroy()
Destroy releases the sub-query resources.
func (*SubQuery) GetFieldName ¶ added in v0.5.0
GetFieldName returns the field name.
func (*SubQuery) GetNumCandidates ¶ added in v0.5.0
GetNumCandidates returns the number of candidates.
func (*SubQuery) SetDiskANNParams ¶ added in v0.6.0
func (q *SubQuery) SetDiskANNParams(params *DiskANNQueryParams) error
SetDiskANNParams sets the DiskANN query parameters on the sub-query (takes ownership).
Available since zvec v0.6.0 (c_api: zvec_sub_query_set_diskann_params). Ownership of params is transferred to the sub-query on success.
func (*SubQuery) SetFTS ¶ added in v0.5.1
SetFTS attaches an FTS clause to the sub-query. The clause is copied; the caller retains ownership of fts.
Available since zvec v0.5.1 (c_api: zvec_sub_query_set_fts).
func (*SubQuery) SetFTSParams ¶ added in v0.5.1
func (q *SubQuery) SetFTSParams(params *FTSQueryParams) error
SetFTSParams sets the FTS query parameters on the sub-query (takes ownership).
Available since zvec v0.5.1 (c_api: zvec_sub_query_set_fts_params). This enables FTS as a sub-query inside a MultiQuery, allowing combinations like FTS + Vector rerank via RRF/Weighted. Ownership of params is transferred to the sub-query on success.
func (*SubQuery) SetFieldName ¶ added in v0.5.0
SetFieldName sets the field name for the sub-query.
func (*SubQuery) SetFlatParams ¶ added in v0.5.0
func (q *SubQuery) SetFlatParams(params *FlatQueryParams) error
SetFlatParams sets the Flat query parameters. Ownership of params is transferred to the sub-query on success.
func (*SubQuery) SetHNSWParams ¶ added in v0.5.0
func (q *SubQuery) SetHNSWParams(params *HNSWQueryParams) error
SetHNSWParams sets the HNSW query parameters. Ownership of params is transferred to the sub-query on success.
func (*SubQuery) SetIVFParams ¶ added in v0.5.0
func (q *SubQuery) SetIVFParams(params *IVFQueryParams) error
SetIVFParams sets the IVF query parameters. Ownership of params is transferred to the sub-query on success.
func (*SubQuery) SetNumCandidates ¶ added in v0.5.0
SetNumCandidates sets the number of candidates to retrieve per field.
func (*SubQuery) SetQueryVector ¶ added in v0.5.0
SetQueryVector sets the query vector data.
type WriteResult ¶
WriteResult holds the result of a write operation (insert/update/upsert/delete).
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
download-libs
command
download-libs downloads the pre-built zvec C-API libraries for the current platform from the upstream zvec-ai/zvec-go GitHub Releases.
|
download-libs downloads the pre-built zvec C-API libraries for the current platform from the upstream zvec-ai/zvec-go GitHub Releases. |
|
examples
|
|
|
fts_query
command
Package main demonstrates Full-Text Search (FTS) in zvec.
|
Package main demonstrates Full-Text Search (FTS) in zvec. |