Documentation
¶
Index ¶
- Constants
- Variables
- func BuildEmbeddingFunctionFromConfig(cfg *CollectionConfigurationImpl) (embeddings.EmbeddingFunction, error)
- func CreateSelfSignedCert(certPath, keyPath string)
- func ValidateArrayMetadata(mv *MetadataValue) error
- func WithEmbeddings(embs ...embeddings.Embedding) *embeddingsOption
- func WithGroupBy(groupBy *GroupBy) *groupByOption
- func WithIDGenerator(idGenerator IDGenerator) *idGeneratorOption
- func WithIDs(ids ...DocumentID) *idsOption
- func WithInclude(include ...Include) *includeOption
- func WithKnnRank(query KnnQueryOption, knnOptions ...KnnOption) *knnRankOption
- func WithLimit(limit int) *limitOption
- func WithMetadatas(metadatas ...DocumentMetadata) *metadatasOption
- func WithNResults(nResults int) *nResultsOption
- func WithOffset(offset int) *offsetOption
- func WithPage(pageOpts ...PageOpts) *pageOptiondeprecated
- func WithQueryEmbeddings(queryEmbeddings ...embeddings.Embedding) *queryEmbeddingsOption
- func WithQueryTexts(texts ...string) *queryTextsOption
- func WithRank(rank Rank) *rankOption
- func WithRffRank(opts ...RrfOption) *rrfRankOptiondeprecated
- func WithRrfRank(opts ...RrfOption) *rrfRankOption
- func WithSearchFilter(filter *SearchFilter) *searchFilterOption
- func WithSearchWhere(where WhereClause) *searchWhereOption
- func WithSelect(projectionKeys ...Key) *selectOption
- func WithSelectAll() *selectAllOption
- func WithTexts(texts ...string) *textsOption
- func WithWhere(where WhereFilter) *whereOption
- func WithWhereDocument(whereDocument WhereDocumentFilter) *whereDocumentOption
- type APIClientV2
- func (client *APIClientV2) Close() error
- func (client *APIClientV2) CountCollections(ctx context.Context, opts ...CountCollectionsOption) (int, error)
- func (client *APIClientV2) CreateCollection(ctx context.Context, name string, options ...CreateCollectionOption) (Collection, error)
- func (client *APIClientV2) CreateDatabase(ctx context.Context, db Database) (Database, error)
- func (client *APIClientV2) CreateTenant(ctx context.Context, tenant Tenant) (Tenant, error)
- func (client *APIClientV2) CurrentDatabase() Database
- func (client *APIClientV2) CurrentTenant() Tenant
- func (client *APIClientV2) DeleteCollection(ctx context.Context, name string, options ...DeleteCollectionOption) error
- func (client *APIClientV2) DeleteDatabase(ctx context.Context, db Database) error
- func (client *APIClientV2) GetCollection(ctx context.Context, name string, opts ...GetCollectionOption) (Collection, error)
- func (client *APIClientV2) GetDatabase(ctx context.Context, db Database) (Database, error)
- func (client *APIClientV2) GetIdentity(ctx context.Context) (Identity, error)
- func (client *APIClientV2) GetOrCreateCollection(ctx context.Context, name string, options ...CreateCollectionOption) (Collection, error)
- func (client *APIClientV2) GetTenant(ctx context.Context, tenant Tenant) (Tenant, error)
- func (client *APIClientV2) GetVersion(ctx context.Context) (string, error)
- func (client *APIClientV2) Heartbeat(ctx context.Context) error
- func (client *APIClientV2) ListCollections(ctx context.Context, opts ...ListCollectionsOption) ([]Collection, error)
- func (client *APIClientV2) ListDatabases(ctx context.Context, tenant Tenant) ([]Database, error)
- func (client *APIClientV2) PreFlight(ctx context.Context) error
- func (client *APIClientV2) Reset(ctx context.Context) error
- func (client *APIClientV2) UseDatabase(ctx context.Context, database Database) error
- func (client *APIClientV2) UseTenant(ctx context.Context, tenant Tenant) errordeprecated
- func (client *APIClientV2) UseTenantDatabase(ctx context.Context, tenant Tenant, database Database) error
- type AbsRank
- func (a *AbsRank) Abs() Rank
- func (a *AbsRank) Add(operand Operand) Rank
- func (a *AbsRank) Div(operand Operand) Rank
- func (a *AbsRank) Exp() Rank
- func (a *AbsRank) IsOperand()
- func (a *AbsRank) Log() Rank
- func (a *AbsRank) MarshalJSON() ([]byte, error)
- func (a *AbsRank) Max(operand Operand) Rank
- func (a *AbsRank) Min(operand Operand) Rank
- func (a *AbsRank) Multiply(operand Operand) Rank
- func (a *AbsRank) Negate() Rank
- func (a *AbsRank) Sub(operand Operand) Rank
- func (a *AbsRank) UnmarshalJSON(_ []byte) error
- type AddOption
- type AddOptionFunc
- type Aggregate
- type BaseAPIClient
- func (bc *BaseAPIClient) BaseURL() string
- func (bc *BaseAPIClient) Database() Database
- func (bc *BaseAPIClient) DefaultHeaders() map[string]string
- func (bc *BaseAPIClient) ExecuteRequest(ctx context.Context, method string, path string, request interface{}) ([]byte, error)
- func (bc *BaseAPIClient) HTTPClient() *http.Client
- func (bc *BaseAPIClient) SendRequest(httpReq *http.Request) (*http.Response, error)
- func (bc *BaseAPIClient) SetTenantAndDatabase(tenant Tenant, database Database)
- func (bc *BaseAPIClient) Tenant() Tenant
- func (bc *BaseAPIClient) TenantAndDatabase() (Tenant, Database)
- func (bc *BaseAPIClient) Timeout() time.Duration
- type BasicAuthCredentialsProvider
- type BoolInvertedIndexConfig
- type BoolInvertedIndexType
- type BoolValueType
- type Client
- type ClientOption
- func WithAuth(authProvider CredentialsProvider) ClientOption
- func WithBaseURL(baseURL string) ClientOption
- func WithCloudAPIKey(apiKey string) ClientOption
- func WithDatabaseAndTenant(database string, tenant string) ClientOption
- func WithDatabaseAndTenantFromEnv() ClientOption
- func WithDebug() ClientOptiondeprecated
- func WithDefaultDatabaseAndTenant() ClientOption
- func WithDefaultHeaders(headers map[string]string) ClientOption
- func WithHTTPClient(httpClient *http.Client) ClientOption
- func WithInsecure() ClientOption
- func WithLogger(l logger.Logger) ClientOption
- func WithSSLCert(certPath string) ClientOption
- func WithTenant(tenant string) ClientOption
- func WithTimeout(timeout time.Duration) ClientOption
- func WithTransport(transport *http.Transport) ClientOption
- type CloudAPIClient
- type CloudClientOption
- type Cmek
- type CmekProvider
- type Collection
- type CollectionAddOp
- func (c *CollectionAddOp) EmbedData(ctx context.Context, ef embeddings.EmbeddingFunction) error
- func (c *CollectionAddOp) GenerateIDs() error
- func (c *CollectionAddOp) MarshalJSON() ([]byte, error)
- func (c *CollectionAddOp) Operation() OperationType
- func (c *CollectionAddOp) PrepareAndValidate() error
- func (c *CollectionAddOp) Resource() Resource
- func (c *CollectionAddOp) UnmarshalJSON(b []byte) error
- type CollectionAddOption
- type CollectionConfiguration
- type CollectionConfigurationImpl
- func (c *CollectionConfigurationImpl) GetEmbeddingFunctionInfo() (*EmbeddingFunctionInfo, bool)
- func (c *CollectionConfigurationImpl) GetRaw(key string) (interface{}, bool)
- func (c *CollectionConfigurationImpl) GetSchema() *Schema
- func (c *CollectionConfigurationImpl) Keys() []string
- func (c *CollectionConfigurationImpl) MarshalJSON() ([]byte, error)
- func (c *CollectionConfigurationImpl) SetEmbeddingFunction(ef embeddings.EmbeddingFunction)
- func (c *CollectionConfigurationImpl) SetEmbeddingFunctionInfo(info *EmbeddingFunctionInfo)
- func (c *CollectionConfigurationImpl) SetRaw(key string, value interface{})
- func (c *CollectionConfigurationImpl) UnmarshalJSON(data []byte) error
- type CollectionDeleteOp
- type CollectionDeleteOption
- type CollectionGetOp
- type CollectionGetOption
- type CollectionImpl
- func (c *CollectionImpl) Add(ctx context.Context, opts ...CollectionAddOption) error
- func (c *CollectionImpl) Close() error
- func (c *CollectionImpl) Configuration() CollectionConfiguration
- func (c *CollectionImpl) Count(ctx context.Context) (int, error)
- func (c *CollectionImpl) Database() Database
- func (c *CollectionImpl) Delete(ctx context.Context, opts ...CollectionDeleteOption) error
- func (c *CollectionImpl) Dimension() int
- func (c *CollectionImpl) Fork(ctx context.Context, newName string) (Collection, error)
- func (c *CollectionImpl) Get(ctx context.Context, opts ...CollectionGetOption) (GetResult, error)
- func (c *CollectionImpl) ID() string
- func (c *CollectionImpl) IndexingStatus(ctx context.Context) (*IndexingStatus, error)
- func (c *CollectionImpl) Metadata() CollectionMetadata
- func (c *CollectionImpl) ModifyConfiguration(ctx context.Context, newConfig *UpdateCollectionConfiguration) error
- func (c *CollectionImpl) ModifyMetadata(ctx context.Context, newMetadata CollectionMetadata) error
- func (c *CollectionImpl) ModifyName(ctx context.Context, newName string) error
- func (c *CollectionImpl) Name() string
- func (c *CollectionImpl) Query(ctx context.Context, opts ...CollectionQueryOption) (QueryResult, error)
- func (c *CollectionImpl) Schema() *Schema
- func (c *CollectionImpl) Search(ctx context.Context, opts ...SearchCollectionOption) (SearchResult, error)
- func (c *CollectionImpl) Tenant() Tenant
- func (c *CollectionImpl) Update(ctx context.Context, opts ...CollectionUpdateOption) error
- func (c *CollectionImpl) Upsert(ctx context.Context, opts ...CollectionAddOption) error
- type CollectionLifecycleOp
- type CollectionMetadata
- type CollectionMetadataImpl
- func (cm *CollectionMetadataImpl) GetBool(key string) (value bool, ok bool)
- func (cm *CollectionMetadataImpl) GetBoolArray(key string) ([]bool, bool)
- func (cm *CollectionMetadataImpl) GetFloat(key string) (value float64, ok bool)
- func (cm *CollectionMetadataImpl) GetFloatArray(key string) ([]float64, bool)
- func (cm *CollectionMetadataImpl) GetInt(key string) (value int64, ok bool)
- func (cm *CollectionMetadataImpl) GetIntArray(key string) ([]int64, bool)
- func (cm *CollectionMetadataImpl) GetRaw(key string) (value interface{}, ok bool)
- func (cm *CollectionMetadataImpl) GetString(key string) (value string, ok bool)
- func (cm *CollectionMetadataImpl) GetStringArray(key string) ([]string, bool)
- func (cm *CollectionMetadataImpl) Keys() []string
- func (cm *CollectionMetadataImpl) MarshalJSON() ([]byte, error)
- func (cm *CollectionMetadataImpl) SetBool(key string, value bool)
- func (cm *CollectionMetadataImpl) SetBoolArray(key string, value []bool)
- func (cm *CollectionMetadataImpl) SetFloat(key string, value float64)
- func (cm *CollectionMetadataImpl) SetFloatArray(key string, value []float64)
- func (cm *CollectionMetadataImpl) SetInt(key string, value int64)
- func (cm *CollectionMetadataImpl) SetIntArray(key string, value []int64)
- func (cm *CollectionMetadataImpl) SetRaw(key string, value interface{})
- func (cm *CollectionMetadataImpl) SetString(key, value string)
- func (cm *CollectionMetadataImpl) SetStringArray(key string, value []string)
- func (cm *CollectionMetadataImpl) UnmarshalJSON(b []byte) error
- type CollectionModel
- type CollectionOp
- type CollectionQueryOp
- func (c *CollectionQueryOp) EmbedData(ctx context.Context, ef embeddings.EmbeddingFunction) error
- func (c *CollectionQueryOp) MarshalJSON() ([]byte, error)
- func (c *CollectionQueryOp) Operation() OperationType
- func (c *CollectionQueryOp) PrepareAndValidate() error
- func (c *CollectionQueryOp) Resource() Resource
- func (c *CollectionQueryOp) UnmarshalJSON(b []byte) error
- type CollectionQueryOption
- type CollectionUpdateOp
- func (c *CollectionUpdateOp) EmbedData(ctx context.Context, ef embeddings.EmbeddingFunction) error
- func (c *CollectionUpdateOp) MarshalJSON() ([]byte, error)
- func (c *CollectionUpdateOp) Operation() OperationType
- func (c *CollectionUpdateOp) PrepareAndValidate() error
- func (c *CollectionUpdateOp) Resource() Resource
- func (c *CollectionUpdateOp) UnmarshalJSON(b []byte) error
- type CollectionUpdateOption
- type CountCollectionsOp
- type CountCollectionsOption
- type CreateCollectionOp
- func (op *CreateCollectionOp) MarshalJSON() ([]byte, error)
- func (op *CreateCollectionOp) Operation() OperationType
- func (op *CreateCollectionOp) PrepareAndValidateCollectionRequest() error
- func (op *CreateCollectionOp) Resource() Resource
- func (op *CreateCollectionOp) String() string
- func (op *CreateCollectionOp) UnmarshalJSON(b []byte) error
- type CreateCollectionOption
- func WithCollectionMetadataCreate(metadata CollectionMetadata) CreateCollectionOption
- func WithCollectionMetadataMapCreateStrict(metadata map[string]interface{}) CreateCollectionOption
- func WithConfigurationCreate(config *CollectionConfigurationImpl) CreateCollectionOption
- func WithDatabaseCreate(database Database) CreateCollectionOption
- func WithDisableEFConfigStorage() CreateCollectionOption
- func WithEmbeddingFunctionCreate(embeddingFunction embeddings.EmbeddingFunction) CreateCollectionOption
- func WithFtsIndexCreate(config *FtsIndexConfig) CreateCollectionOption
- func WithHNSWBatchSizeCreate(batchSize int) CreateCollectionOption
- func WithHNSWConstructionEfCreate(efConstruction int) CreateCollectionOption
- func WithHNSWMCreate(m int) CreateCollectionOption
- func WithHNSWNumThreadsCreate(numThreads int) CreateCollectionOption
- func WithHNSWResizeFactorCreate(resizeFactor float64) CreateCollectionOption
- func WithHNSWSearchEfCreate(efSearch int) CreateCollectionOption
- func WithHNSWSpaceCreate(metric embeddings.DistanceMetric) CreateCollectionOption
- func WithHNSWSyncThresholdCreate(syncThreshold int) CreateCollectionOption
- func WithIfNotExistsCreate() CreateCollectionOption
- func WithSchemaCreate(schema *Schema) CreateCollectionOption
- func WithVectorIndexCreate(config *VectorIndexConfig) CreateCollectionOption
- type CredentialsProvider
- type Database
- type DatabaseBase
- type DeleteCollectionOp
- type DeleteCollectionOption
- type DeleteOption
- type DeleteOptionFunc
- type DivRank
- func (d *DivRank) Abs() Rank
- func (d *DivRank) Add(operand Operand) Rank
- func (d *DivRank) Div(operand Operand) Rank
- func (d *DivRank) Exp() Rank
- func (d *DivRank) IsOperand()
- func (d *DivRank) Log() Rank
- func (d *DivRank) MarshalJSON() ([]byte, error)
- func (d *DivRank) Max(operand Operand) Rank
- func (d *DivRank) Min(operand Operand) Rank
- func (d *DivRank) Multiply(operand Operand) Rank
- func (d *DivRank) Negate() Rank
- func (d *DivRank) Sub(operand Operand) Rank
- func (d *DivRank) UnmarshalJSON(_ []byte) error
- type Document
- type DocumentID
- type DocumentIDs
- type DocumentMetadata
- type DocumentMetadataImpl
- func (cm *DocumentMetadataImpl) GetBool(key string) (value bool, ok bool)
- func (cm *DocumentMetadataImpl) GetBoolArray(key string) ([]bool, bool)
- func (cm *DocumentMetadataImpl) GetFloat(key string) (value float64, ok bool)
- func (cm *DocumentMetadataImpl) GetFloatArray(key string) ([]float64, bool)
- func (cm *DocumentMetadataImpl) GetInt(key string) (value int64, ok bool)
- func (cm *DocumentMetadataImpl) GetIntArray(key string) ([]int64, bool)
- func (cm *DocumentMetadataImpl) GetRaw(key string) (value interface{}, ok bool)
- func (cm *DocumentMetadataImpl) GetString(key string) (value string, ok bool)
- func (cm *DocumentMetadataImpl) GetStringArray(key string) ([]string, bool)
- func (cm *DocumentMetadataImpl) Keys() []string
- func (cm *DocumentMetadataImpl) MarshalJSON() ([]byte, error)
- func (cm *DocumentMetadataImpl) SetBool(key string, value bool)
- func (cm *DocumentMetadataImpl) SetBoolArray(key string, value []bool)
- func (cm *DocumentMetadataImpl) SetFloat(key string, value float64)
- func (cm *DocumentMetadataImpl) SetFloatArray(key string, value []float64)
- func (cm *DocumentMetadataImpl) SetInt(key string, value int64)
- func (cm *DocumentMetadataImpl) SetIntArray(key string, value []int64)
- func (cm *DocumentMetadataImpl) SetRaw(key string, value interface{})
- func (cm *DocumentMetadataImpl) SetString(key, value string)
- func (cm *DocumentMetadataImpl) SetStringArray(key string, value []string)
- func (cm *DocumentMetadataImpl) UnmarshalJSON(b []byte) error
- type DocumentMetadatas
- type Documents
- type EmbeddingFunctionInfo
- type ExpRank
- func (e *ExpRank) Abs() Rank
- func (e *ExpRank) Add(operand Operand) Rank
- func (e *ExpRank) Div(operand Operand) Rank
- func (e *ExpRank) Exp() Rank
- func (e *ExpRank) IsOperand()
- func (e *ExpRank) Log() Rank
- func (e *ExpRank) MarshalJSON() ([]byte, error)
- func (e *ExpRank) Max(operand Operand) Rank
- func (e *ExpRank) Min(operand Operand) Rank
- func (e *ExpRank) Multiply(operand Operand) Rank
- func (e *ExpRank) Negate() Rank
- func (e *ExpRank) Sub(operand Operand) Rank
- func (e *ExpRank) UnmarshalJSON(_ []byte) error
- type FilterEmbeddingsOp
- type FilterIDOp
- type FilterOp
- type FilterTextsOp
- type FloatInvertedIndexConfig
- type FloatInvertedIndexType
- type FloatListValueType
- type FloatOperand
- type FloatValueType
- type FtsIndexConfig
- type FtsIndexType
- type GenerateOptions
- type GetCollectionOp
- type GetCollectionOption
- type GetOption
- func WithIDsGet(ids ...DocumentID) GetOptiondeprecated
- func WithIncludeGet(include ...Include) GetOptiondeprecated
- func WithLimitGet(limit int) GetOptiondeprecated
- func WithOffsetGet(offset int) GetOptiondeprecated
- func WithWhereDocumentGet(whereDocument WhereDocumentFilter) GetOptiondeprecated
- func WithWhereGet(where WhereFilter) GetOptiondeprecated
- type GetOptionFunc
- type GetResult
- type GetResultImpl
- func (r *GetResultImpl) At(index int) (ResultRow, bool)
- func (r *GetResultImpl) Count() int
- func (r *GetResultImpl) GetDocuments() Documents
- func (r *GetResultImpl) GetEmbeddings() embeddings.Embeddings
- func (r *GetResultImpl) GetIDs() DocumentIDs
- func (r *GetResultImpl) GetMetadatas() DocumentMetadatas
- func (r *GetResultImpl) Next() (GetResult, error)
- func (r *GetResultImpl) Rows() []ResultRow
- func (r *GetResultImpl) String() string
- func (r *GetResultImpl) ToRecords() Records
- func (r *GetResultImpl) UnmarshalJSON(data []byte) error
- type GroupBy
- type HnswIndexConfig
- type HnswOption
- func WithBatchSize(size uint) HnswOption
- func WithEfConstruction(ef uint) HnswOption
- func WithEfSearch(ef uint) HnswOption
- func WithMaxNeighbors(m uint) HnswOption
- func WithNumThreads(n uint) HnswOption
- func WithResizeFactor(factor float64) HnswOption
- func WithSyncThreshold(threshold uint) HnswOption
- type IDGenerator
- type IDGeneratorOption
- type Identity
- type Include
- type IndexingStatus
- type IntInvertedIndexConfig
- type IntInvertedIndexType
- type IntOperand
- type IntValueType
- type Key
- type KnnOption
- type KnnQueryOption
- type KnnRank
- func (k *KnnRank) Abs() Rank
- func (k *KnnRank) Add(operand Operand) Rank
- func (k *KnnRank) Div(operand Operand) Rank
- func (k *KnnRank) Exp() Rank
- func (k *KnnRank) IsOperand()
- func (k *KnnRank) Log() Rank
- func (k *KnnRank) MarshalJSON() ([]byte, error)
- func (k *KnnRank) Max(operand Operand) Rank
- func (k *KnnRank) Min(operand Operand) Rank
- func (k *KnnRank) Multiply(operand Operand) Rank
- func (k *KnnRank) Negate() Rank
- func (k *KnnRank) Sub(operand Operand) Rank
- func (k *KnnRank) UnmarshalJSON(b []byte) error
- func (k *KnnRank) WithWeight(weight float64) RankWithWeight
- type LimitAndOffsetOp
- type LimitResultOp
- type ListCollectionOp
- type ListCollectionsOption
- type LogRank
- func (l *LogRank) Abs() Rank
- func (l *LogRank) Add(operand Operand) Rank
- func (l *LogRank) Div(operand Operand) Rank
- func (l *LogRank) Exp() Rank
- func (l *LogRank) IsOperand()
- func (l *LogRank) Log() Rank
- func (l *LogRank) MarshalJSON() ([]byte, error)
- func (l *LogRank) Max(operand Operand) Rank
- func (l *LogRank) Min(operand Operand) Rank
- func (l *LogRank) Multiply(operand Operand) Rank
- func (l *LogRank) Negate() Rank
- func (l *LogRank) Sub(operand Operand) Rank
- func (l *LogRank) UnmarshalJSON(_ []byte) error
- type MaxK
- type MaxRank
- func (m *MaxRank) Abs() Rank
- func (m *MaxRank) Add(operand Operand) Rank
- func (m *MaxRank) Div(operand Operand) Rank
- func (m *MaxRank) Exp() Rank
- func (m *MaxRank) IsOperand()
- func (m *MaxRank) Log() Rank
- func (m *MaxRank) MarshalJSON() ([]byte, error)
- func (m *MaxRank) Max(operand Operand) Rank
- func (m *MaxRank) Min(operand Operand) Rank
- func (m *MaxRank) Multiply(operand Operand) Rank
- func (m *MaxRank) Negate() Rank
- func (m *MaxRank) Sub(operand Operand) Rank
- func (m *MaxRank) UnmarshalJSON(_ []byte) error
- type MetaAttribute
- func NewBoolArrayAttribute(key string, values []bool) *MetaAttribute
- func NewBoolAttribute(key string, value bool) *MetaAttribute
- func NewFloatArrayAttribute(key string, values []float64) *MetaAttribute
- func NewFloatAttribute(key string, value float64) *MetaAttribute
- func NewIntArrayAttribute(key string, values []int64) *MetaAttribute
- func NewIntAttribute(key string, value int64) *MetaAttribute
- func NewStringArrayAttribute(key string, values []string) *MetaAttribute
- func NewStringAttribute(key string, value string) *MetaAttribute
- func RemoveAttribute(key string) *MetaAttribute
- type MetadataValue
- func (mv *MetadataValue) Equal(other *MetadataValue) bool
- func (mv *MetadataValue) GetBool() (bool, bool)
- func (mv *MetadataValue) GetBoolArray() ([]bool, bool)
- func (mv *MetadataValue) GetFloat() (float64, bool)
- func (mv *MetadataValue) GetFloatArray() ([]float64, bool)
- func (mv *MetadataValue) GetInt() (int64, bool)
- func (mv *MetadataValue) GetIntArray() ([]int64, bool)
- func (mv *MetadataValue) GetRaw() (interface{}, bool)
- func (mv *MetadataValue) GetString() (string, bool)
- func (mv *MetadataValue) GetStringArray() ([]string, bool)
- func (mv *MetadataValue) MarshalJSON() ([]byte, error)
- func (mv *MetadataValue) String() string
- func (mv *MetadataValue) UnmarshalJSON(b []byte) error
- type MinK
- type MinRank
- func (m *MinRank) Abs() Rank
- func (m *MinRank) Add(operand Operand) Rank
- func (m *MinRank) Div(operand Operand) Rank
- func (m *MinRank) Exp() Rank
- func (m *MinRank) IsOperand()
- func (m *MinRank) Log() Rank
- func (m *MinRank) MarshalJSON() ([]byte, error)
- func (m *MinRank) Max(operand Operand) Rank
- func (m *MinRank) Min(operand Operand) Rank
- func (m *MinRank) Multiply(operand Operand) Rank
- func (m *MinRank) Negate() Rank
- func (m *MinRank) Sub(operand Operand) Rank
- func (m *MinRank) UnmarshalJSON(_ []byte) error
- type ModifyConfigOption
- func WithHNSWBatchSizeModify(v uint) ModifyConfigOption
- func WithHNSWEfSearchModify(v uint) ModifyConfigOption
- func WithHNSWNumThreadsModify(v uint) ModifyConfigOption
- func WithHNSWResizeFactorModify(v float64) ModifyConfigOption
- func WithHNSWSyncThresholdModify(v uint) ModifyConfigOption
- func WithSpannEfSearchModify(v uint) ModifyConfigOption
- func WithSpannSearchNprobeModify(v uint) ModifyConfigOption
- type MulRank
- func (m *MulRank) Abs() Rank
- func (m *MulRank) Add(operand Operand) Rank
- func (m *MulRank) Div(operand Operand) Rank
- func (m *MulRank) Exp() Rank
- func (m *MulRank) IsOperand()
- func (m *MulRank) Log() Rank
- func (m *MulRank) MarshalJSON() ([]byte, error)
- func (m *MulRank) Max(operand Operand) Rank
- func (m *MulRank) Min(operand Operand) Rank
- func (m *MulRank) Multiply(operand Operand) Rank
- func (m *MulRank) Negate() Rank
- func (m *MulRank) Sub(operand Operand) Rank
- func (m *MulRank) UnmarshalJSON(_ []byte) error
- type Operand
- type OperationType
- type Option
- type Page
- type PageOption
- type PageOptsdeprecated
- func PageLimit(limit int) PageOptsdeprecated
- func PageOffset(offset int) PageOptsdeprecated
- func SearchWithLimit(limit int) PageOptsdeprecated
- func SearchWithOffset(offset int) PageOptsdeprecated
- type PersistentClient
- type PersistentClientOption
- func WithPersistentAllowReset(allowReset bool) PersistentClientOption
- func WithPersistentClientOption(option ClientOption) PersistentClientOption
- func WithPersistentClientOptions(options ...ClientOption) PersistentClientOption
- func WithPersistentConfigPath(path string) PersistentClientOption
- func WithPersistentLibraryAutoDownload(enabled bool) PersistentClientOption
- func WithPersistentLibraryCacheDir(path string) PersistentClientOption
- func WithPersistentLibraryPath(path string) PersistentClientOption
- func WithPersistentLibraryVersion(version string) PersistentClientOption
- func WithPersistentListenAddress(address string) PersistentClientOption
- func WithPersistentPath(path string) PersistentClientOption
- func WithPersistentPort(port int) PersistentClientOption
- func WithPersistentRawYAML(yaml string) PersistentClientOption
- func WithPersistentRuntimeMode(mode PersistentRuntimeMode) PersistentClientOption
- type PersistentRuntimeMode
- type ProjectOp
- type QueryOption
- type QueryOptionFunc
- type QueryResult
- type QueryResultImpl
- func (r *QueryResultImpl) At(group, index int) (ResultRow, bool)
- func (r *QueryResultImpl) CountGroups() int
- func (r *QueryResultImpl) GetDistancesGroups() []embeddings.Distances
- func (r *QueryResultImpl) GetDocumentsGroups() []Documents
- func (r *QueryResultImpl) GetEmbeddingsGroups() []embeddings.Embeddings
- func (r *QueryResultImpl) GetIDGroups() []DocumentIDs
- func (r *QueryResultImpl) GetMetadatasGroups() []DocumentMetadatas
- func (r *QueryResultImpl) RowGroups() [][]ResultRow
- func (r *QueryResultImpl) Rows() []ResultRow
- func (r *QueryResultImpl) String() string
- func (r *QueryResultImpl) ToRecordsGroups() []Records
- func (r *QueryResultImpl) UnmarshalJSON(data []byte) error
- type Rank
- type RankWithWeight
- type ReadLevel
- type Record
- type RecordOption
- type Records
- type Resource
- type ResourceOperation
- type ResultRow
- type RffOptiondeprecated
- type RrfOption
- type RrfRank
- func (r *RrfRank) Abs() Rank
- func (r *RrfRank) Add(operand Operand) Rank
- func (r *RrfRank) Div(operand Operand) Rank
- func (r *RrfRank) Exp() Rank
- func (r *RrfRank) IsOperand()
- func (r *RrfRank) Log() Rank
- func (r *RrfRank) MarshalJSON() ([]byte, error)
- func (r *RrfRank) Max(operand Operand) Rank
- func (r *RrfRank) Min(operand Operand) Rank
- func (r *RrfRank) Multiply(operand Operand) Rank
- func (r *RrfRank) Negate() Rank
- func (r *RrfRank) Sub(operand Operand) Rank
- func (r *RrfRank) UnmarshalJSON(_ []byte) error
- func (r *RrfRank) Validate() error
- type SHA256Generator
- type Schema
- func (s *Schema) Cmek() *Cmek
- func (s *Schema) Defaults() *ValueTypes
- func (s *Schema) GetAllSparseEmbeddingFunctions() map[string]embeddings.SparseEmbeddingFunction
- func (s *Schema) GetEmbeddingFunction() embeddings.EmbeddingFunction
- func (s *Schema) GetKey(key string) (*ValueTypes, bool)
- func (s *Schema) GetSparseEmbeddingFunction(key string) embeddings.SparseEmbeddingFunction
- func (s *Schema) IsFtsEnabled() bool
- func (s *Schema) Keys() []string
- func (s *Schema) MarshalJSON() ([]byte, error)
- func (s *Schema) SetEmbeddingFunction(ef embeddings.EmbeddingFunction)
- func (s *Schema) SetSparseEmbeddingFunction(key string, ef embeddings.SparseEmbeddingFunction)
- func (s *Schema) UnmarshalJSON(data []byte) error
- type SchemaOption
- func DisableBoolIndex(key string) SchemaOption
- func DisableDefaultBoolIndex() SchemaOption
- func DisableDefaultFloatIndex() SchemaOption
- func DisableDefaultFtsIndex() SchemaOptiondeprecated
- func DisableDefaultIntIndex() SchemaOption
- func DisableDefaultStringIndex() SchemaOption
- func DisableDocumentFtsIndex() SchemaOption
- func DisableFloatIndex(key string) SchemaOption
- func DisableFtsIndex(key string) SchemaOption
- func DisableIntIndex(key string) SchemaOption
- func DisableStringIndex(key string) SchemaOption
- func WithBoolIndex(key string) SchemaOption
- func WithCmek(cmek *Cmek) SchemaOption
- func WithDefaultFtsIndex(cfg *FtsIndexConfig) SchemaOption
- func WithDefaultSparseVectorIndex(cfg *SparseVectorIndexConfig) SchemaOption
- func WithDefaultVectorIndex(cfg *VectorIndexConfig) SchemaOption
- func WithFloatIndex(key string) SchemaOption
- func WithFtsIndex(key string) SchemaOption
- func WithIntIndex(key string) SchemaOption
- func WithSparseVectorIndex(key string, cfg *SparseVectorIndexConfig) SchemaOption
- func WithStringIndex(key string) SchemaOption
- func WithVectorIndex(key string, cfg *VectorIndexConfig) SchemaOption
- type SearchCollectionOption
- type SearchFilter
- type SearchOption
- type SearchPagedeprecated
- type SearchQuery
- type SearchRequest
- type SearchRequestOption
- type SearchRequestOptionFunc
- type SearchResult
- type SearchResultImpl
- type SearchSelect
- type SimpleRecord
- func (r *SimpleRecord) Document() Document
- func (r *SimpleRecord) Embedding() embeddings.Embedding
- func (r *SimpleRecord) ID() DocumentID
- func (r *SimpleRecord) Metadata() DocumentMetadata
- func (r *SimpleRecord) URI() string
- func (r *SimpleRecord) Unwrap() (DocumentID, Document, embeddings.Embedding, DocumentMetadata)
- func (r *SimpleRecord) Validate() error
- type SortOp
- type Space
- type SpannIndexConfig
- type SpannOption
- func WithSpannEfConstruction(ef uint) SpannOption
- func WithSpannEfSearch(ef uint) SpannOption
- func WithSpannInitialLambda(l float64) SpannOption
- func WithSpannMaxNeighbors(m uint) SpannOption
- func WithSpannMergeThreshold(t uint) SpannOption
- func WithSpannNReplicaCount(n uint) SpannOption
- func WithSpannNumCentersToMergeTo(n uint) SpannOption
- func WithSpannNumSamplesKmeans(n uint) SpannOption
- func WithSpannQuantize(q SpannQuantization) SpannOption
- func WithSpannReassignNeighborCount(n uint) SpannOption
- func WithSpannSearchNprobe(n uint) SpannOption
- func WithSpannSearchRngEpsilon(e float64) SpannOption
- func WithSpannSearchRngFactor(f float64) SpannOption
- func WithSpannSplitThreshold(t uint) SpannOption
- func WithSpannWriteNprobe(n uint) SpannOption
- func WithSpannWriteRngEpsilon(e float64) SpannOption
- func WithSpannWriteRngFactor(f float64) SpannOption
- type SpannQuantization
- type SparseVectorIndexConfig
- type SparseVectorIndexOption
- type SparseVectorIndexType
- type SparseVectorValueType
- type StringInvertedIndexConfig
- type StringInvertedIndexType
- type StringValueType
- type SubRank
- func (s *SubRank) Abs() Rank
- func (s *SubRank) Add(operand Operand) Rank
- func (s *SubRank) Div(operand Operand) Rank
- func (s *SubRank) Exp() Rank
- func (s *SubRank) IsOperand()
- func (s *SubRank) Log() Rank
- func (s *SubRank) MarshalJSON() ([]byte, error)
- func (s *SubRank) Max(operand Operand) Rank
- func (s *SubRank) Min(operand Operand) Rank
- func (s *SubRank) Multiply(operand Operand) Rank
- func (s *SubRank) Negate() Rank
- func (s *SubRank) Sub(operand Operand) Rank
- func (s *SubRank) UnmarshalJSON(_ []byte) error
- type SumRank
- func (s *SumRank) Abs() Rank
- func (s *SumRank) Add(operand Operand) Rank
- func (s *SumRank) Div(operand Operand) Rank
- func (s *SumRank) Exp() Rank
- func (s *SumRank) IsOperand()
- func (s *SumRank) Log() Rank
- func (s *SumRank) MarshalJSON() ([]byte, error)
- func (s *SumRank) Max(operand Operand) Rank
- func (s *SumRank) Min(operand Operand) Rank
- func (s *SumRank) Multiply(operand Operand) Rank
- func (s *SumRank) Negate() Rank
- func (s *SumRank) Sub(operand Operand) Rank
- func (s *SumRank) UnmarshalJSON(_ []byte) error
- type Tenant
- type TenantBase
- type TextDocument
- type TextDocuments
- type TokenAuthCredentialsProvider
- type TokenTransportHeader
- type ULIDGenerator
- type UUIDGenerator
- type UnknownRank
- type UpdateCollectionConfiguration
- type UpdateHNSWConfiguration
- type UpdateOption
- type UpdateOptionFunc
- type UpdateSpannConfiguration
- type ValRank
- func (v *ValRank) Abs() Rank
- func (v *ValRank) Add(operand Operand) Rank
- func (v *ValRank) Div(operand Operand) Rank
- func (v *ValRank) Exp() Rank
- func (v *ValRank) IsOperand()
- func (v *ValRank) Log() Rank
- func (v *ValRank) MarshalJSON() ([]byte, error)
- func (v *ValRank) Max(operand Operand) Rank
- func (v *ValRank) Min(operand Operand) Rank
- func (v *ValRank) Multiply(operand Operand) Rank
- func (v *ValRank) Negate() Rank
- func (v *ValRank) Sub(operand Operand) Rank
- func (v *ValRank) UnmarshalJSON(b []byte) error
- type ValueTypes
- type VectorIndexConfig
- type VectorIndexOption
- type VectorIndexType
- type WhereClause
- func And(clauses ...WhereClause) WhereClause
- func DocumentContains(text string) WhereClause
- func DocumentNotContains(text string) WhereClause
- func EqBool(field Key, value bool) WhereClause
- func EqFloat(field Key, value float32) WhereClause
- func EqInt(field Key, value int) WhereClause
- func EqString(field Key, value string) WhereClause
- func GtFloat(field Key, value float32) WhereClause
- func GtInt(field Key, value int) WhereClause
- func GteFloat(field Key, value float32) WhereClause
- func GteInt(field Key, value int) WhereClause
- func IDIn(ids ...DocumentID) WhereClause
- func IDNotIn(ids ...DocumentID) WhereClause
- func InBool(field Key, values ...bool) WhereClause
- func InFloat(field Key, values ...float32) WhereClause
- func InInt(field Key, values ...int) WhereClause
- func InString(field Key, values ...string) WhereClause
- func LtFloat(field Key, value float32) WhereClause
- func LtInt(field Key, value int) WhereClause
- func LteFloat(field Key, value float32) WhereClause
- func LteInt(field Key, value int) WhereClause
- func MetadataContainsBool(field Key, value bool) WhereClause
- func MetadataContainsFloat(field Key, value float32) WhereClause
- func MetadataContainsInt(field Key, value int) WhereClause
- func MetadataContainsString(field Key, value string) WhereClause
- func MetadataNotContainsBool(field Key, value bool) WhereClause
- func MetadataNotContainsFloat(field Key, value float32) WhereClause
- func MetadataNotContainsInt(field Key, value int) WhereClause
- func MetadataNotContainsString(field Key, value string) WhereClause
- func NinBool(field Key, values ...bool) WhereClause
- func NinFloat(field Key, values ...float32) WhereClause
- func NinInt(field Key, values ...int) WhereClause
- func NinString(field Key, values ...string) WhereClause
- func NotEqBool(field Key, value bool) WhereClause
- func NotEqFloat(field Key, value float32) WhereClause
- func NotEqInt(field Key, value int) WhereClause
- func NotEqString(field Key, value string) WhereClause
- func Or(clauses ...WhereClause) WhereClause
- type WhereClauseBase
- type WhereClauseBool
- type WhereClauseBools
- type WhereClauseFloat
- type WhereClauseFloats
- type WhereClauseInt
- type WhereClauseInts
- type WhereClauseString
- type WhereClauseStrings
- type WhereClauseWhereClauses
- type WhereDocumentClauseAnd
- type WhereDocumentClauseContainsOrNotContains
- type WhereDocumentClauseOr
- type WhereDocumentClauseRegexNotRegex
- type WhereDocumentFilter
- func AndDocument(clauses ...WhereDocumentFilter) WhereDocumentFilter
- func Contains(content string) WhereDocumentFilter
- func NotContains(content string) WhereDocumentFilter
- func NotRegex(content string) WhereDocumentFilter
- func OrDocument(clauses ...WhereDocumentFilter) WhereDocumentFilter
- func Regex(content string) WhereDocumentFilter
- type WhereDocumentFilterBase
- func (w *WhereDocumentFilterBase) MarshalJSON() ([]byte, error)
- func (w *WhereDocumentFilterBase) Operand() interface{}
- func (w *WhereDocumentFilterBase) Operator() WhereDocumentFilterOperator
- func (w *WhereDocumentFilterBase) String() string
- func (w *WhereDocumentFilterBase) UnmarshalJSON(b []byte) error
- func (w *WhereDocumentFilterBase) Validate() error
- type WhereDocumentFilterOperator
- type WhereFilter
- type WhereFilterOperator
Constants ¶
const ( OperationCreate OperationType = "create" OperationGet OperationType = "read" OperationQuery OperationType = "query" OperationUpdate OperationType = "update" OperationDelete OperationType = "delete" ResourceTenant Resource = "tenant" ResourceDatabase Resource = "database" ResourceCollection Resource = "collection" ResourceInstance Resource = "instance" )
const ( DefaultTenant = "default_tenant" DefaultDatabase = "default_database" HNSWSpace = "hnsw:space" HNSWConstructionEF = "hnsw:construction_ef" HNSWBatchSize = "hnsw:batch_size" HNSWSyncThreshold = "hnsw:sync_threshold" HNSWM = "hnsw:M" HNSWSearchEF = "hnsw:search_ef" HNSWNumThreads = "hnsw:num_threads" HNSWResizeFactor = "hnsw:resize_factor" )
const ( DocumentKey = "#document" EmbeddingKey = "#embedding" )
Reserved keys for system-managed fields
const ChromaCloudEndpoint = "https://api.trychroma.com:8000/api/v2"
const MaxExpressionDepth = 100
MaxExpressionDepth is the maximum nesting depth for rank expressions to prevent stack overflow.
const MaxExpressionTerms = 1000
MaxExpressionTerms is the maximum number of terms allowed in variadic rank expressions (Sum, Mul, Max, Min).
const MaxRrfRanks = 100
NewRrfRank creates a Reciprocal Rank Fusion ranking expression.
Example:
rrf, err := NewRrfRank(
WithRrfRanks(
NewKnnRank(KnnQueryText("query"), WithKnnReturnRank()).WithWeight(1.0),
),
WithRrfK(60),
WithRrfNormalize(),
)
MaxRrfRanks is the maximum number of ranks allowed in RRF to prevent excessive memory allocation.
Variables ¶
var ( // ErrInvalidLimit is returned when [WithLimit] receives a value <= 0. ErrInvalidLimit = errors.New("limit must be greater than 0") // ErrInvalidOffset is returned when [WithOffset] receives a negative value. ErrInvalidOffset = errors.New("offset must be greater than or equal to 0") // ErrInvalidNResults is returned when [WithNResults] receives a value <= 0. ErrInvalidNResults = errors.New("nResults must be greater than 0") // ErrNoQueryTexts is returned when [WithQueryTexts] is called with no texts. ErrNoQueryTexts = errors.New("at least one query text is required") // ErrNoTexts is returned when [WithTexts] is called with no texts. ErrNoTexts = errors.New("at least one text is required") // ErrNoMetadatas is returned when [WithMetadatas] is called with no metadatas. ErrNoMetadatas = errors.New("at least one metadata is required") )
Option validation errors.
These errors are returned when option validation fails during operation construction.
Functions ¶
func BuildEmbeddingFunctionFromConfig ¶ added in v0.3.0
func BuildEmbeddingFunctionFromConfig(cfg *CollectionConfigurationImpl) (embeddings.EmbeddingFunction, error)
BuildEmbeddingFunctionFromConfig attempts to reconstruct an embedding function from the configuration. First tries to get EF from configuration.embedding_function, then from schema if present. Returns nil without error if: - Configuration is nil - No embedding_function in config and no schema with EF - Type is not "known" - Name not registered in the dense registry Returns error if the factory fails to build the embedding function.
func CreateSelfSignedCert ¶
func CreateSelfSignedCert(certPath, keyPath string)
func ValidateArrayMetadata ¶ added in v0.3.5
func ValidateArrayMetadata(mv *MetadataValue) error
ValidateArrayMetadata checks that array metadata values are non-empty.
func WithEmbeddings ¶
func WithEmbeddings(embs ...embeddings.Embedding) *embeddingsOption
WithEmbeddings sets pre-computed embeddings for [Collection.Add], [Collection.Upsert], and [Collection.Update] operations.
Use this when you have already computed embeddings externally and don't want the collection's embedding function to re-embed the documents.
The number of embeddings must match the number of IDs provided. Each embedding is a slice of float32 values.
Example ¶
// Pre-computed 384-dimensional embeddings
emb1 := []float32{0.1, 0.2, ...}
emb2 := []float32{0.3, 0.4, ...}
err := collection.Add(ctx,
WithIDs("doc1", "doc2"),
WithEmbeddings(emb1, emb2),
WithMetadatas(meta1, meta2),
)
func WithGroupBy ¶ added in v0.3.0
func WithGroupBy(groupBy *GroupBy) *groupByOption
WithGroupBy groups results by metadata keys using the specified aggregation.
Example:
result, err := col.Search(ctx,
NewSearchRequest(
WithKnnRank(KnnQueryText("query"), WithKnnLimit(100)),
WithGroupBy(NewGroupBy(NewMinK(3, KScore), K("category"))),
WithPage(PageLimit(30)),
),
)
func WithIDGenerator ¶
func WithIDGenerator(idGenerator IDGenerator) *idGeneratorOption
WithIDGenerator sets an automatic ID generator for [Collection.Add].
When an ID generator is set, IDs are automatically generated for each document based on the generator's strategy. This allows adding documents without explicitly providing IDs.
Available generators:
- NewULIDGenerator - generates unique, lexicographically sortable IDs
- NewUUIDGenerator - generates random UUIDs
- NewSHA256Generator - generates content-based IDs (deterministic)
Example with ULID Generator ¶
err := collection.Add(ctx,
WithTexts("First document", "Second document"),
WithIDGenerator(NewULIDGenerator()),
)
Example with Content-Based IDs ¶
// Same content always produces the same ID
err := collection.Add(ctx,
WithTexts("Document content"),
WithIDGenerator(NewSHA256Generator()),
)
func WithIDs ¶
func WithIDs(ids ...DocumentID) *idsOption
WithIDs specifies document IDs for filtering or identification.
This is a unified option that works with multiple operations:
- [Collection.Get]: Retrieve specific documents by ID
- [Collection.Query]: Limit semantic search to specific documents
- [Collection.Delete]: Delete specific documents by ID
- [Collection.Add]: Specify IDs for new documents
- [Collection.Update]: Identify documents to update
- [Collection.Search]: Filter search results to specific IDs
Get Example ¶
results, err := collection.Get(ctx, WithIDs("doc1", "doc2", "doc3"))
Query Example ¶
results, err := collection.Query(ctx,
WithQueryTexts("machine learning"),
WithIDs("doc1", "doc2"), // Only search within these documents
)
Delete Example ¶
err := collection.Delete(ctx, WithIDs("doc1", "doc2"))
Add Example ¶
err := collection.Add(ctx,
WithIDs("doc1", "doc2"),
WithTexts("First document", "Second document"),
)
Note: Calling WithIDs multiple times will append IDs to support incremental array construction in the columnar API. Duplicate IDs (within a call or across calls) will return an error immediately. At least one ID must be provided.
func WithInclude ¶ added in v0.3.2
func WithInclude(include ...Include) *includeOption
WithInclude specifies which fields to include in Get and Query results.
This option works with:
- [Collection.Get]: Control which fields are returned
- [Collection.Query]: Control which fields are returned with search results
Available Include Constants ¶
- IncludeDocuments - include document text content
- IncludeMetadatas - include document metadata
- IncludeEmbeddings - include vector embeddings
- IncludeDistances - include distance scores (Query only)
- IncludeURIs - include document URIs
By default, Get returns documents and metadatas. Query returns IDs and distances.
Note: Calling WithInclude multiple times will overwrite the previous value. Include fields are idempotent - specifying the same field multiple times has no additional effect.
Get Example ¶
results, err := collection.Get(ctx,
WithIDs("doc1", "doc2"),
WithInclude(IncludeDocuments, IncludeMetadatas, IncludeEmbeddings),
)
Query Example ¶
results, err := collection.Query(ctx,
WithQueryTexts("machine learning"),
WithInclude(IncludeDocuments, IncludeDistances),
WithNResults(10),
)
func WithKnnRank ¶ added in v0.3.0
func WithKnnRank(query KnnQueryOption, knnOptions ...KnnOption) *knnRankOption
Example:
search := NewSearchRequest(
WithKnnRank(KnnQueryText("machine learning"), WithKnnLimit(50)),
WithPage(PageLimit(10)),
)
func WithLimit ¶ added in v0.3.0
func WithLimit(limit int) *limitOption
WithLimit sets the maximum number of results to return.
Works with both [Collection.Get] and [Collection.Search]. Use with WithOffset for pagination. The limit must be greater than 0.
For [Collection.Query], use WithNResults instead.
Get Example ¶
results, err := collection.Get(ctx, WithLimit(100))
Search Example ¶
result, err := collection.Search(ctx,
NewSearchRequest(
WithKnnRank(KnnQueryText("query")),
WithLimit(10),
WithOffset(20),
),
)
Pagination Example ¶
// Get page 3 (documents 200-299)
results, err := collection.Get(ctx,
WithLimit(100),
WithOffset(200),
)
func WithMetadatas ¶
func WithMetadatas(metadatas ...DocumentMetadata) *metadatasOption
WithMetadatas sets document metadata for [Collection.Add], [Collection.Upsert], and [Collection.Update] operations.
The number of metadatas must match the number of IDs provided. Each metadata is a map of string keys to values (string, int, float, bool, or arrays of these types).
Add Example ¶
meta1 := map[string]any{"author": "Alice", "year": 2024}
meta2 := map[string]any{"author": "Bob", "year": 2023}
err := collection.Add(ctx,
WithIDs("doc1", "doc2"),
WithTexts("First document", "Second document"),
WithMetadatas(meta1, meta2),
)
Update Example ¶
err := collection.Update(ctx,
WithIDs("doc1"),
WithMetadatas(map[string]any{"status": "reviewed"}),
)
Note: At least one metadata must be provided.
func WithNResults ¶
func WithNResults(nResults int) *nResultsOption
WithNResults sets the number of nearest neighbors to return from [Collection.Query].
This controls how many semantically similar documents are returned per query. The value must be greater than 0. Default is 10 if not specified.
For [Collection.Get], use WithLimit instead. For [Collection.Search], use WithPage with PageLimit instead.
Example ¶
results, err := collection.Query(ctx,
WithQueryTexts("machine learning"),
WithNResults(5),
)
Multiple Query Example ¶
// Each query text returns up to 5 results
results, err := collection.Query(ctx,
WithQueryTexts("AI", "robotics", "automation"),
WithNResults(5),
)
func WithOffset ¶ added in v0.3.0
func WithOffset(offset int) *offsetOption
WithOffset sets the number of results to skip.
Works with both [Collection.Get] and [Collection.Search]. Use with WithLimit for pagination. The offset must be >= 0.
Get Pagination Example ¶
pageSize := 25
pageNum := 3 // 0-indexed
results, err := collection.Get(ctx,
WithLimit(pageSize),
WithOffset(pageNum * pageSize),
)
Search Pagination Example ¶
result, err := collection.Search(ctx,
NewSearchRequest(
WithKnnRank(KnnQueryText("query")),
WithLimit(20),
WithOffset(40), // Page 3
),
)
func WithPage
deprecated
added in
v0.3.0
func WithPage(pageOpts ...PageOpts) *pageOption
Deprecated: Use NewPage with Limit and Offset instead.
Migration Example ¶
Before:
NewSearchRequest(WithPage(PageLimit(20), PageOffset(40)))
After (using Page):
page, _ := NewPage(Limit(20), Offset(40)) NewSearchRequest(page)
Or (using WithLimit/WithOffset directly):
NewSearchRequest(WithLimit(20), WithOffset(40))
func WithQueryEmbeddings ¶
func WithQueryEmbeddings(queryEmbeddings ...embeddings.Embedding) *queryEmbeddingsOption
WithQueryEmbeddings sets the query embeddings. Works with Query.
func WithQueryTexts ¶
func WithQueryTexts(texts ...string) *queryTextsOption
WithQueryTexts sets the text queries for semantic search in [Collection.Query].
The texts are embedded using the collection's embedding function and used to find semantically similar documents. At least one text is required.
Each query text produces a separate result set. Use WithNResults to control how many results are returned per query.
For pre-computed embeddings, use WithQueryEmbeddings instead.
Single Query Example ¶
results, err := collection.Query(ctx,
WithQueryTexts("What is machine learning?"),
WithNResults(10),
)
Multiple Query Example ¶
results, err := collection.Query(ctx,
WithQueryTexts(
"machine learning algorithms",
"deep neural networks",
"natural language processing",
),
WithNResults(5),
)
// results.IDs[0] contains results for first query
// results.IDs[1] contains results for second query
// results.IDs[2] contains results for third query
func WithRank ¶ added in v0.3.0
func WithRank(rank Rank) *rankOption
WithRank sets a custom ranking expression on the search request. Use this for complex rank expressions built from arithmetic operations.
Example:
knn1, _ := NewKnnRank(KnnQueryText("query1"))
knn2, _ := NewKnnRank(KnnQueryText("query2"))
combined := knn1.Multiply(FloatOperand(0.7)).Add(knn2.Multiply(FloatOperand(0.3)))
result, err := col.Search(ctx,
NewSearchRequest(
WithRank(combined),
WithPage(PageLimit(10)),
),
)
func WithRffRank
deprecated
added in
v0.3.0
func WithRffRank(opts ...RrfOption) *rrfRankOption
Deprecated: Use WithRrfRank instead.
func WithRrfRank ¶ added in v0.3.2
func WithRrfRank(opts ...RrfOption) *rrfRankOption
WithRrfRank adds an RRF ranking expression to a search request.
Example:
search := NewSearchRequest(
WithRrfRank(
WithRrfRanks(
NewKnnRank(KnnQueryText("q1"), WithKnnReturnRank()).WithWeight(0.5),
NewKnnRank(KnnQueryText("q2"), WithKnnReturnRank()).WithWeight(0.5),
),
),
)
func WithSearchFilter ¶ added in v0.3.0
func WithSearchFilter(filter *SearchFilter) *searchFilterOption
WithSearchFilter sets a pre-built SearchFilter on the search request.
For most cases, use WithFilter and WithIDs instead, which are simpler.
func WithSearchWhere ¶ added in v0.3.2
func WithSearchWhere(where WhereClause) *searchWhereOption
WithSearchWhere filters [Collection.Search] results by metadata.
This option uses the Search API's WhereClause filter syntax, which differs slightly from the Query API's WhereFilter. Use K to create field keys.
For a more intuitive API, consider using WithFilter which is an alias.
Available Filter Functions ¶
Equality:
Comparison:
- GtInt, GtFloat, [GtString]
- GteInt, GteFloat, [GteString]
- LtInt, LtFloat, [LtString]
- LteInt, LteFloat, [LteString]
Set operations:
Logical:
Special:
- IDIn - filter by document IDs
Example ¶
result, err := collection.Search(ctx,
NewSearchRequest(
WithKnnRank(KnnQueryText("query")),
WithSearchWhere(And(
EqString(K("status"), "published"),
GtInt(K("views"), 1000),
)),
),
)
func WithSelect ¶ added in v0.3.0
func WithSelect(projectionKeys ...Key) *selectOption
WithSelect specifies which fields to include in search results.
By default, only IDs are returned. Use this to include additional fields like document content, embeddings, scores, or specific metadata fields.
Standard Fields ¶
- KID - document ID (usually included by default)
- KDocument - document text content
- KEmbedding - vector embedding
- KScore - ranking/similarity score
- KMetadata - all metadata as a map
Custom Metadata Fields ¶
Use K("field_name") to select specific metadata fields.
Example ¶
NewSearchRequest(
WithKnnRank(KnnQueryText("query")),
WithSelect(KDocument, KScore, K("title"), K("author")),
)
func WithSelectAll ¶ added in v0.3.0
func WithSelectAll() *selectAllOption
WithSelectAll includes all standard fields in search results.
Equivalent to WithSelect(KID, KDocument, KEmbedding, KMetadata, KScore).
Example ¶
NewSearchRequest(
WithKnnRank(KnnQueryText("query")),
WithSelectAll(),
)
func WithTexts ¶
func WithTexts(texts ...string) *textsOption
WithTexts sets the document text content for [Collection.Add], [Collection.Upsert], and [Collection.Update] operations.
The texts are automatically embedded using the collection's embedding function unless embeddings are also provided via WithEmbeddings.
The number of texts must match the number of IDs provided via WithIDs.
Add Example ¶
err := collection.Add(ctx,
WithIDs("doc1", "doc2", "doc3"),
WithTexts(
"Introduction to machine learning",
"Deep learning fundamentals",
"Natural language processing basics",
),
)
Update Example ¶
err := collection.Update(ctx,
WithIDs("doc1"),
WithTexts("Updated: Introduction to machine learning v2"),
)
Upsert Example ¶
err := collection.Upsert(ctx,
WithIDs("doc1", "doc2"),
WithTexts("New or updated doc 1", "New or updated doc 2"),
WithMetadatas(meta1, meta2),
)
Note: Calling WithTexts multiple times will append texts to support incremental array construction in the columnar API. This aligns with WithIDs behavior. At least one text must be provided.
func WithWhere ¶ added in v0.3.2
func WithWhere(where WhereFilter) *whereOption
WithWhere filters documents by metadata field values.
This is a unified option that works with:
- [Collection.Get]: Filter which documents to retrieve
- [Collection.Query]: Filter semantic search results
- [Collection.Delete]: Delete documents matching the filter
Note: Calling WithWhere multiple times will overwrite the previous filter, not merge them. To combine filters, use [AndFilter] or [OrFilter].
Available Filter Functions ¶
Equality:
Comparison (numeric/string):
- GtInt, GtFloat, [GtString] - greater than
- GteInt, GteFloat, [GteString] - greater than or equal
- LtInt, LtFloat, [LtString] - less than
- LteInt, LteFloat, [LteString] - less than or equal
Set operations:
Logical:
- [AndFilter], [OrFilter] - combine multiple filters
Get Example ¶
results, err := collection.Get(ctx,
WithWhere(EqString("status", "published")),
)
Query Example ¶
results, err := collection.Query(ctx,
WithQueryTexts("machine learning"),
WithWhere(AndFilter(
EqString("category", "tech"),
GtInt("views", 1000),
)),
)
Delete Example ¶
err := collection.Delete(ctx,
WithWhere(EqString("status", "archived")),
)
func WithWhereDocument ¶ added in v0.3.2
func WithWhereDocument(whereDocument WhereDocumentFilter) *whereDocumentOption
WithWhereDocument filters documents by their text content.
This is a unified option that works with:
- [Collection.Get]: Filter which documents to retrieve
- [Collection.Query]: Filter semantic search results
- [Collection.Delete]: Delete documents matching the content filter
Note: Calling WithWhereDocument multiple times will overwrite the previous filter, not merge them. To combine filters, use [AndDocumentFilter] or [OrDocumentFilter].
Available Filter Functions ¶
- Contains - document contains the substring
- NotContains - document does not contain the substring
- [AndDocumentFilter] - combine multiple document filters with AND
- [OrDocumentFilter] - combine multiple document filters with OR
Get Example ¶
results, err := collection.Get(ctx,
WithWhereDocument(Contains("machine learning")),
)
Query Example ¶
results, err := collection.Query(ctx,
WithQueryTexts("AI research"),
WithWhereDocument(AndDocumentFilter(
Contains("neural network"),
NotContains("deprecated"),
)),
)
Delete Example ¶
err := collection.Delete(ctx,
WithWhereDocument(Contains("DRAFT:")),
)
Types ¶
type APIClientV2 ¶
type APIClientV2 struct {
BaseAPIClient
// contains filtered or unexported fields
}
func (*APIClientV2) Close ¶
func (client *APIClientV2) Close() error
func (*APIClientV2) CountCollections ¶
func (client *APIClientV2) CountCollections(ctx context.Context, opts ...CountCollectionsOption) (int, error)
func (*APIClientV2) CreateCollection ¶
func (client *APIClientV2) CreateCollection(ctx context.Context, name string, options ...CreateCollectionOption) (Collection, error)
func (*APIClientV2) CreateDatabase ¶
func (*APIClientV2) CreateTenant ¶
func (*APIClientV2) CurrentDatabase ¶
func (client *APIClientV2) CurrentDatabase() Database
func (*APIClientV2) CurrentTenant ¶
func (client *APIClientV2) CurrentTenant() Tenant
func (*APIClientV2) DeleteCollection ¶
func (client *APIClientV2) DeleteCollection(ctx context.Context, name string, options ...DeleteCollectionOption) error
func (*APIClientV2) DeleteDatabase ¶
func (client *APIClientV2) DeleteDatabase(ctx context.Context, db Database) error
func (*APIClientV2) GetCollection ¶
func (client *APIClientV2) GetCollection(ctx context.Context, name string, opts ...GetCollectionOption) (Collection, error)
func (*APIClientV2) GetDatabase ¶
func (*APIClientV2) GetIdentity ¶
func (client *APIClientV2) GetIdentity(ctx context.Context) (Identity, error)
func (*APIClientV2) GetOrCreateCollection ¶
func (client *APIClientV2) GetOrCreateCollection(ctx context.Context, name string, options ...CreateCollectionOption) (Collection, error)
func (*APIClientV2) GetVersion ¶
func (client *APIClientV2) GetVersion(ctx context.Context) (string, error)
func (*APIClientV2) ListCollections ¶
func (client *APIClientV2) ListCollections(ctx context.Context, opts ...ListCollectionsOption) ([]Collection, error)
func (*APIClientV2) ListDatabases ¶
func (*APIClientV2) UseDatabase ¶
func (client *APIClientV2) UseDatabase(ctx context.Context, database Database) error
UseDatabase validates and switches the active database. The tenant is derived from the database object itself.
func (*APIClientV2) UseTenant
deprecated
func (client *APIClientV2) UseTenant(ctx context.Context, tenant Tenant) error
Deprecated: Use UseTenantDatabase on a concrete client (*APIClientV2) to validate remote state and atomically update the local tenant/database pair. The generic Client interface does not expose UseTenantDatabase.
func (*APIClientV2) UseTenantDatabase ¶ added in v0.4.0
func (client *APIClientV2) UseTenantDatabase(ctx context.Context, tenant Tenant, database Database) error
UseTenantDatabase validates tenant/database against the server, then updates the local active tenant/database pair under a single lock acquisition.
type AbsRank ¶ added in v0.3.0
type AbsRank struct {
// contains filtered or unexported fields
}
AbsRank represents the absolute value of a rank expression. Serializes to JSON as {"$abs": <rank>}.
func (*AbsRank) MarshalJSON ¶ added in v0.3.0
func (*AbsRank) UnmarshalJSON ¶ added in v0.3.0
type AddOption ¶ added in v0.3.2
type AddOption interface {
ApplyToAdd(*CollectionAddOp) error
}
AddOption configures a [Collection.Add] or [Collection.Upsert] operation. Implementations include WithIDs, WithTexts, WithEmbeddings, WithMetadatas, and WithIDGenerator.
type AddOptionFunc ¶ added in v0.3.2
type AddOptionFunc func(*CollectionAddOp) error
AddOptionFunc wraps a function as an AddOption. Use this to create custom Add options without defining a new type.
func (AddOptionFunc) ApplyToAdd ¶ added in v0.3.2
func (f AddOptionFunc) ApplyToAdd(op *CollectionAddOp) error
ApplyToAdd implements AddOption.
type BaseAPIClient ¶
type BaseAPIClient struct {
// contains filtered or unexported fields
}
BaseAPIClient holds shared client transport/configuration state. scopeMu protects tenant and database from concurrent access and is set by newBaseAPIClient. defaultHeaders must not be mutated after newBaseAPIClient returns; no lock is needed to read it. Zero-value BaseAPIClient instances share a package-level fallback mutex.
func (*BaseAPIClient) BaseURL ¶
func (bc *BaseAPIClient) BaseURL() string
func (*BaseAPIClient) Database ¶
func (bc *BaseAPIClient) Database() Database
func (*BaseAPIClient) DefaultHeaders ¶
func (bc *BaseAPIClient) DefaultHeaders() map[string]string
DefaultHeaders returns a copy of the default headers. Headers are immutable after construction; the copy prevents callers from mutating internal state.
func (*BaseAPIClient) ExecuteRequest ¶
func (*BaseAPIClient) HTTPClient ¶
func (bc *BaseAPIClient) HTTPClient() *http.Client
func (*BaseAPIClient) SendRequest ¶
func (*BaseAPIClient) SetTenantAndDatabase ¶ added in v0.4.0
func (bc *BaseAPIClient) SetTenantAndDatabase(tenant Tenant, database Database)
func (*BaseAPIClient) Tenant ¶
func (bc *BaseAPIClient) Tenant() Tenant
func (*BaseAPIClient) TenantAndDatabase ¶ added in v0.4.0
func (bc *BaseAPIClient) TenantAndDatabase() (Tenant, Database)
TenantAndDatabase returns a lock-consistent snapshot of the current tenant and database.
func (*BaseAPIClient) Timeout ¶
func (bc *BaseAPIClient) Timeout() time.Duration
type BasicAuthCredentialsProvider ¶
func NewBasicAuthCredentialsProvider ¶
func NewBasicAuthCredentialsProvider(username, password string) *BasicAuthCredentialsProvider
func (*BasicAuthCredentialsProvider) Authenticate ¶
func (b *BasicAuthCredentialsProvider) Authenticate() (map[string]string, error)
func (*BasicAuthCredentialsProvider) String ¶ added in v0.2.4
func (b *BasicAuthCredentialsProvider) String() string
type BoolInvertedIndexConfig ¶ added in v0.3.0
type BoolInvertedIndexConfig struct{}
type BoolInvertedIndexType ¶ added in v0.3.0
type BoolInvertedIndexType struct {
Enabled bool `json:"enabled"`
Config *BoolInvertedIndexConfig `json:"config,omitempty"`
}
BoolInvertedIndexType wraps BoolInvertedIndexConfig with enabled state
type BoolValueType ¶ added in v0.3.0
type BoolValueType struct {
BoolInvertedIndex *BoolInvertedIndexType `json:"bool_inverted_index,omitempty"`
}
BoolValueType defines indexes for boolean metadata
type Client ¶
type Client interface {
PreFlight(ctx context.Context) error
// Heartbeat checks if the chroma instance is alive.
Heartbeat(ctx context.Context) error
// GetVersion returns the version of the chroma instance.
GetVersion(ctx context.Context) (string, error)
// GetIdentity returns the identity of the chroma instance. This is noop for v1 API.
GetIdentity(ctx context.Context) (Identity, error)
// GetTenant gets a tenant with the given name.
GetTenant(ctx context.Context, tenant Tenant) (Tenant, error)
// UseTenant sets the current tenant to the given name and resets the active
// database to [DefaultDatabase] for that tenant.
UseTenant(ctx context.Context, tenant Tenant) error
// UseDatabase sets a database to use for all collection operations.
UseDatabase(ctx context.Context, database Database) error
// CreateTenant creates a new tenant with the given name.
CreateTenant(ctx context.Context, tenant Tenant) (Tenant, error)
// ListDatabases returns a list of databases in the given tenant.
ListDatabases(ctx context.Context, tenant Tenant) ([]Database, error)
// GetDatabase gets a database with the given name from the given tenant.
GetDatabase(ctx context.Context, db Database) (Database, error)
// CreateDatabase creates a new database with the given name in the given tenant.
CreateDatabase(ctx context.Context, db Database) (Database, error)
// DeleteDatabase deletes a database with the given name from the given tenant.
DeleteDatabase(ctx context.Context, db Database) error
// CurrentTenant returns the current tenant.
CurrentTenant() Tenant
// CurrentDatabase returns the current database.
CurrentDatabase() Database
// Reset resets the chroma instance by all data. Use with caution.
// Returns an error if ALLOW_RESET is not set to true.
Reset(ctx context.Context) error
// CreateCollection creates a new collection with the given name and options.
CreateCollection(ctx context.Context, name string, options ...CreateCollectionOption) (Collection, error)
// GetOrCreateCollection gets a collection with the given name. If the collection does not exist, it creates a new collection with the given options.
// If the collection exists but the metadata does not match the options, it returns an error. Use Collection.ModifyMetadata to update the metadata.
GetOrCreateCollection(ctx context.Context, name string, options ...CreateCollectionOption) (Collection, error)
// DeleteCollection deletes the collection with the given name.
DeleteCollection(ctx context.Context, name string, options ...DeleteCollectionOption) error
// GetCollection gets a collection with the given name.
GetCollection(ctx context.Context, name string, opts ...GetCollectionOption) (Collection, error)
// CountCollections returns the number of collections in the current tenant and database.
CountCollections(ctx context.Context, opts ...CountCollectionsOption) (int, error)
// ListCollections returns a list of collections in the current tenant and database.
ListCollections(ctx context.Context, opts ...ListCollectionsOption) ([]Collection, error)
// Close closes the client and releases any resources.
Close() error
}
func NewHTTPClient ¶
func NewHTTPClient(opts ...ClientOption) (Client, error)
func NewPersistentClient ¶ added in v0.4.0
func NewPersistentClient(opts ...PersistentClientOption) (Client, error)
NewPersistentClient creates a Chroma client that starts and manages an in-process local Chroma runtime.
Embedded mode is used by default. Use WithPersistentRuntimeMode (or server-specific options such as WithPersistentPort) to run a local HTTP server mode instead.
type ClientOption ¶
type ClientOption func(client *BaseAPIClient) error
func WithAuth ¶
func WithAuth(authProvider CredentialsProvider) ClientOption
func WithBaseURL ¶
func WithBaseURL(baseURL string) ClientOption
func WithCloudAPIKey ¶ added in v0.2.4
func WithCloudAPIKey(apiKey string) ClientOption
WithCloudAPIKey sets the API key for the cloud client. It will automatically set a new TokenAuthCredentialsProvider.
func WithDatabaseAndTenant ¶
func WithDatabaseAndTenant(database string, tenant string) ClientOption
func WithDatabaseAndTenantFromEnv ¶ added in v0.2.5
func WithDatabaseAndTenantFromEnv() ClientOption
WithDatabaseAndTenantFromEnv sets the tenant and database from environment variables CHROMA_TENANT and CHROMA_DATABASE
func WithDebug
deprecated
func WithDebug() ClientOption
Deprecated: Use WithLogger with debug level enabled. See https://github.com/amikos-tech/chroma-go/blob/ad35b6d37f9be4431687945ae4a77470e0832cf4/examples/v2/logging/main.go This function now automatically creates a development logger for backward compatibility. Will be removed in v0.3.0.
func WithDefaultDatabaseAndTenant ¶ added in v0.2.5
func WithDefaultDatabaseAndTenant() ClientOption
func WithDefaultHeaders ¶
func WithDefaultHeaders(headers map[string]string) ClientOption
func WithHTTPClient ¶
func WithHTTPClient(httpClient *http.Client) ClientOption
func WithInsecure ¶
func WithInsecure() ClientOption
WithInsecure skips SSL verification. It is mutually exclusive with WithHTTPClient and this is enforced at construction time. DO NOT USE IN PRODUCTION.
func WithLogger ¶ added in v0.3.0
func WithLogger(l logger.Logger) ClientOption
WithLogger sets a custom logger for the client. If not set, a NoopLogger is used by default.
func WithSSLCert ¶
func WithSSLCert(certPath string) ClientOption
WithSSLCert adds a custom SSL certificate to the client. The certificate must be in PEM format. The option can be added multiple times to add multiple certificates. It is mutually exclusive with WithHTTPClient and this is enforced at construction time.
func WithTenant ¶
func WithTenant(tenant string) ClientOption
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ClientOption
func WithTransport ¶
func WithTransport(transport *http.Transport) ClientOption
type CloudAPIClient ¶ added in v0.2.4
type CloudAPIClient struct {
*APIClientV2
}
func NewCloudAPIClient
deprecated
added in
v0.2.4
func NewCloudAPIClient(options ...ClientOption) (*CloudAPIClient, error)
Deprecated: use NewCloudClient instead
func NewCloudClient ¶ added in v0.2.5
func NewCloudClient(options ...ClientOption) (*CloudAPIClient, error)
type CloudClientOption ¶ added in v0.2.4
type CloudClientOption func(client *CloudAPIClient) error
type Cmek ¶ added in v0.3.0
type Cmek struct {
Provider CmekProvider
Resource string
}
Cmek represents a customer-managed encryption key configuration
func NewGCPCmek ¶ added in v0.3.0
NewGCPCmek creates a CMEK configuration for Google Cloud Platform KMS. The resource should be in the format: projects/{project-id}/locations/{location}/keyRings/{key-ring}/cryptoKeys/{key}
Validation occurs when the CMEK is added to a schema via WithCmek. For early validation, call ValidatePattern() on the returned Cmek.
func (*Cmek) MarshalJSON ¶ added in v0.3.0
MarshalJSON serializes CMEK to the variant format {"provider": "resource"}
func (*Cmek) UnmarshalJSON ¶ added in v0.3.0
UnmarshalJSON deserializes CMEK from the variant format {"provider": "resource"} and validates the resource format.
func (*Cmek) ValidatePattern ¶ added in v0.3.0
ValidatePattern validates the CMEK resource format for the provider. This validates format only; it does not verify key accessibility.
type CmekProvider ¶ added in v0.3.0
type CmekProvider string
CmekProvider represents supported cloud providers for customer-managed encryption keys
const (
CmekProviderGCP CmekProvider = "gcp"
)
type Collection ¶
type Collection interface {
// Name returns the name of the collection.
Name() string
// ID returns the unique identifier of the collection.
ID() string
// Tenant returns the tenant that owns this collection.
Tenant() Tenant
// Database returns the database containing this collection.
Database() Database
// Metadata returns the collection's metadata.
Metadata() CollectionMetadata
// Dimension returns the dimensionality of embeddings in this collection.
// Returns 0 if not yet determined (no documents added).
Dimension() int
// Configuration returns the collection's configuration settings.
Configuration() CollectionConfiguration
// Schema returns the collection's schema definition, if any.
Schema() *Schema
// Add inserts new documents into the collection.
//
// Documents can be provided as text (automatically embedded) or with
// pre-computed embeddings. IDs must be unique within the collection.
//
// Options: [WithIDs], [WithTexts], [WithEmbeddings], [WithMetadatas], [WithIDGenerator]
//
// err := collection.Add(ctx,
// WithIDs("doc1", "doc2"),
// WithTexts("First document", "Second document"),
// )
Add(ctx context.Context, opts ...CollectionAddOption) error
// Upsert inserts new documents or updates existing ones.
//
// If a document with the given ID exists, it is updated. Otherwise, a new
// document is created. Uses the same options as [Collection.Add].
//
// err := collection.Upsert(ctx,
// WithIDs("doc1"),
// WithTexts("New or updated content"),
// )
Upsert(ctx context.Context, opts ...CollectionAddOption) error
// Update modifies existing documents in the collection.
//
// Only the provided fields are updated. Documents must exist.
//
// Options: [WithIDs], [WithTexts], [WithEmbeddings], [WithMetadatas]
//
// err := collection.Update(ctx,
// WithIDs("doc1"),
// WithTexts("Updated content"),
// )
Update(ctx context.Context, opts ...CollectionUpdateOption) error
// Delete removes documents from the collection.
//
// At least one filter must be provided: IDs, Where, or WhereDocument.
//
// Options: [WithIDs], [WithWhere], [WithWhereDocument]
//
// // Delete by ID
// err := collection.Delete(ctx, WithIDs("doc1", "doc2"))
//
// // Delete by metadata filter
// err := collection.Delete(ctx, WithWhere(EqString("status", "archived")))
Delete(ctx context.Context, opts ...CollectionDeleteOption) error
// Count returns the total number of documents in the collection.
Count(ctx context.Context) (int, error)
// ModifyName changes the collection's name.
ModifyName(ctx context.Context, newName string) error
// ModifyMetadata updates the collection's metadata.
ModifyMetadata(ctx context.Context, newMetadata CollectionMetadata) error
// ModifyConfiguration updates the collection's configuration.
// Note: Not all configuration changes may be supported.
ModifyConfiguration(ctx context.Context, newConfig *UpdateCollectionConfiguration) error
// Get retrieves documents from the collection by ID or filter.
//
// Returns documents matching the specified criteria. If no filters are
// provided, returns all documents (subject to limit/offset).
//
// Options: [WithIDs], [WithWhere], [WithWhereDocument], [WithInclude], [WithLimit], [WithOffset]
//
// // Get by IDs
// results, _ := collection.Get(ctx, WithIDs("doc1", "doc2"))
//
// // Get with pagination
// results, _ := collection.Get(ctx, WithLimit(100), WithOffset(200))
//
// // Get with filter
// results, _ := collection.Get(ctx,
// WithWhere(EqString("status", "published")),
// WithInclude(IncludeDocuments, IncludeMetadatas),
// )
Get(ctx context.Context, opts ...CollectionGetOption) (GetResult, error)
// Query performs semantic search using text or embeddings.
//
// Finds documents most similar to the query. Use [WithQueryTexts] for text
// queries (automatically embedded) or [WithQueryEmbeddings] for pre-computed
// embeddings.
//
// Options: [WithQueryTexts], [WithQueryEmbeddings], [WithNResults], [WithWhere],
// [WithWhereDocument], [WithInclude], [WithIDs]
//
// results, _ := collection.Query(ctx,
// WithQueryTexts("machine learning"),
// WithNResults(10),
// WithWhere(EqString("category", "tech")),
// )
Query(ctx context.Context, opts ...CollectionQueryOption) (QueryResult, error)
// Search performs advanced search with ranking and filtering.
//
// Provides more control than Query, including custom ranking expressions,
// pagination, field selection, and grouping.
//
// Use [NewSearchRequest] to create search requests with options like
// [WithKnnRank], [WithFilter], [WithPage], [WithSelect], and [WithGroupBy].
//
// results, _ := collection.Search(ctx,
// NewSearchRequest(
// WithKnnRank(KnnQueryText("machine learning")),
// WithFilter(EqString(K("status"), "published")),
// WithPage(PageLimit(10)),
// WithSelect(KDocument, KScore),
// ),
// )
Search(ctx context.Context, opts ...SearchCollectionOption) (SearchResult, error)
// Fork creates a copy of this collection with a new name.
// The new collection contains all documents from the original.
Fork(ctx context.Context, newName string) (Collection, error)
// IndexingStatus returns the current indexing progress for this collection.
// Requires Chroma server version >= 1.4.1.
//
// Use this to monitor background indexing after adding large amounts of data.
IndexingStatus(ctx context.Context) (*IndexingStatus, error)
// Close releases any resources held by the collection.
// The collection should not be used after calling Close.
Close() error
}
Collection represents a Chroma vector collection.
A Collection stores documents with their embeddings, metadata, and optional URIs. It provides methods for CRUD operations and semantic search.
Creating a Collection ¶
Use [Client.CreateCollection] or [Client.GetOrCreateCollection]:
client, _ := NewClient()
collection, _ := client.CreateCollection(ctx, "my-collection",
WithEmbeddingFunction(ef),
WithCollectionMetadata(map[string]any{"description": "My docs"}),
)
Adding Documents ¶
Use [Collection.Add] with unified options:
err := collection.Add(ctx,
WithIDs("doc1", "doc2"),
WithTexts("First document", "Second document"),
WithMetadatas(meta1, meta2),
)
Querying Documents ¶
Use [Collection.Query] for semantic search or [Collection.Get] for direct retrieval:
// Semantic search
results, _ := collection.Query(ctx,
WithQueryTexts("machine learning"),
WithNResults(10),
)
// Direct retrieval
results, _ := collection.Get(ctx,
WithIDs("doc1", "doc2"),
)
Advanced Search ¶
Use [Collection.Search] for more control over ranking and filtering:
results, _ := collection.Search(ctx,
NewSearchRequest(
WithKnnRank(KnnQueryText("query")),
WithFilter(EqString(K("status"), "published")),
WithPage(PageLimit(20)),
),
)
type CollectionAddOp ¶ added in v0.2.3
type CollectionAddOp struct {
// Ids are the unique identifiers for each document.
Ids []DocumentID `json:"ids"`
// Documents contain the text content to be stored and embedded.
Documents []Document `json:"documents,omitempty"`
// Metadatas contain key-value metadata for each document.
Metadatas []DocumentMetadata `json:"metadatas,omitempty"`
// Embeddings are the vector representations of the documents.
// If not provided, they are computed from Documents using the embedding function.
Embeddings []any `json:"embeddings"`
// Records is an alternative to separate Ids/Documents/Metadatas/Embeddings.
Records []Record `json:"-"`
// IDGenerator automatically generates IDs if Ids is empty.
IDGenerator IDGenerator `json:"-"`
}
CollectionAddOp represents an Add or Upsert operation.
Use [Collection.Add] or [Collection.Upsert] with options:
err := collection.Add(ctx,
WithIDs("doc1", "doc2"),
WithTexts("First document", "Second document"),
WithMetadatas(meta1, meta2),
)
func NewCollectionAddOp ¶ added in v0.2.3
func NewCollectionAddOp(opts ...AddOption) (*CollectionAddOp, error)
NewCollectionAddOp creates a new Add operation with the given options.
This is primarily for advanced use cases. Most users should use [Collection.Add] or [Collection.Upsert] directly.
func (*CollectionAddOp) EmbedData ¶ added in v0.2.3
func (c *CollectionAddOp) EmbedData(ctx context.Context, ef embeddings.EmbeddingFunction) error
func (*CollectionAddOp) GenerateIDs ¶ added in v0.2.3
func (c *CollectionAddOp) GenerateIDs() error
func (*CollectionAddOp) MarshalJSON ¶ added in v0.2.3
func (c *CollectionAddOp) MarshalJSON() ([]byte, error)
func (*CollectionAddOp) Operation ¶ added in v0.2.3
func (c *CollectionAddOp) Operation() OperationType
func (*CollectionAddOp) PrepareAndValidate ¶ added in v0.2.3
func (c *CollectionAddOp) PrepareAndValidate() error
func (*CollectionAddOp) Resource ¶ added in v0.2.3
func (c *CollectionAddOp) Resource() Resource
func (*CollectionAddOp) UnmarshalJSON ¶ added in v0.2.3
func (c *CollectionAddOp) UnmarshalJSON(b []byte) error
type CollectionAddOption ¶ added in v0.2.3
type CollectionAddOption = AddOption
CollectionAddOption is an alias for AddOption for backward compatibility.
type CollectionConfiguration ¶
type CollectionConfiguration interface {
// GetRaw returns a configuration value by key.
// Returns the value and true if found, or nil and false if not found.
GetRaw(key string) (any, bool)
}
CollectionConfiguration provides access to collection configuration settings.
type CollectionConfigurationImpl ¶ added in v0.3.0
type CollectionConfigurationImpl struct {
// contains filtered or unexported fields
}
CollectionConfigurationImpl is the concrete implementation of CollectionConfiguration
func NewCollectionConfiguration ¶ added in v0.3.0
func NewCollectionConfiguration() *CollectionConfigurationImpl
NewCollectionConfiguration creates a new CollectionConfigurationImpl with the given schema
func NewCollectionConfigurationFromMap ¶ added in v0.3.0
func NewCollectionConfigurationFromMap(raw map[string]interface{}) *CollectionConfigurationImpl
NewCollectionConfigurationFromMap creates a CollectionConfigurationImpl from a raw map This is useful when deserializing from API responses
func (*CollectionConfigurationImpl) GetEmbeddingFunctionInfo ¶ added in v0.3.0
func (c *CollectionConfigurationImpl) GetEmbeddingFunctionInfo() (*EmbeddingFunctionInfo, bool)
GetEmbeddingFunctionInfo extracts the embedding function configuration from the collection configuration
func (*CollectionConfigurationImpl) GetRaw ¶ added in v0.3.0
func (c *CollectionConfigurationImpl) GetRaw(key string) (interface{}, bool)
GetRaw returns the raw value for a given key
func (*CollectionConfigurationImpl) GetSchema ¶ added in v0.3.0
func (c *CollectionConfigurationImpl) GetSchema() *Schema
GetSchema extracts the Schema from the configuration if present Returns nil if no schema is found or if unmarshaling fails
func (*CollectionConfigurationImpl) Keys ¶ added in v0.3.0
func (c *CollectionConfigurationImpl) Keys() []string
Keys returns all keys in the configuration
func (*CollectionConfigurationImpl) MarshalJSON ¶ added in v0.3.0
func (c *CollectionConfigurationImpl) MarshalJSON() ([]byte, error)
MarshalJSON serializes the configuration to JSON
func (*CollectionConfigurationImpl) SetEmbeddingFunction ¶ added in v0.3.0
func (c *CollectionConfigurationImpl) SetEmbeddingFunction(ef embeddings.EmbeddingFunction)
SetEmbeddingFunction creates an EmbeddingFunctionInfo from an EmbeddingFunction and stores it
func (*CollectionConfigurationImpl) SetEmbeddingFunctionInfo ¶ added in v0.3.0
func (c *CollectionConfigurationImpl) SetEmbeddingFunctionInfo(info *EmbeddingFunctionInfo)
SetEmbeddingFunctionInfo sets the embedding function configuration in the collection configuration
func (*CollectionConfigurationImpl) SetRaw ¶ added in v0.3.0
func (c *CollectionConfigurationImpl) SetRaw(key string, value interface{})
SetRaw sets a raw value for a given key
func (*CollectionConfigurationImpl) UnmarshalJSON ¶ added in v0.3.0
func (c *CollectionConfigurationImpl) UnmarshalJSON(data []byte) error
UnmarshalJSON deserializes the configuration from JSON
type CollectionDeleteOp ¶
type CollectionDeleteOp struct {
FilterOp // Where and WhereDocument filters
FilterIDOp // ID filter
}
CollectionDeleteOp represents a Delete operation on a collection.
At least one filter must be provided: IDs, Where, or WhereDocument.
Use [Collection.Delete] with options:
// Delete by ID
err := collection.Delete(ctx, WithIDs("doc1", "doc2"))
// Delete by metadata filter
err := collection.Delete(ctx, WithWhere(EqString("status", "archived")))
// Delete by document content
err := collection.Delete(ctx, WithWhereDocument(Contains("DEPRECATED")))
func NewCollectionDeleteOp ¶
func NewCollectionDeleteOp(opts ...DeleteOption) (*CollectionDeleteOp, error)
NewCollectionDeleteOp creates a new Delete operation with the given options.
This is primarily for advanced use cases. Most users should use [Collection.Delete] directly.
func (*CollectionDeleteOp) MarshalJSON ¶
func (c *CollectionDeleteOp) MarshalJSON() ([]byte, error)
func (*CollectionDeleteOp) Operation ¶
func (c *CollectionDeleteOp) Operation() OperationType
func (*CollectionDeleteOp) PrepareAndValidate ¶
func (c *CollectionDeleteOp) PrepareAndValidate() error
func (*CollectionDeleteOp) Resource ¶
func (c *CollectionDeleteOp) Resource() Resource
func (*CollectionDeleteOp) UnmarshalJSON ¶
func (c *CollectionDeleteOp) UnmarshalJSON(b []byte) error
type CollectionDeleteOption ¶
type CollectionDeleteOption = DeleteOption
CollectionDeleteOption is an alias for DeleteOption for backward compatibility.
type CollectionGetOp ¶
type CollectionGetOp struct {
FilterOp // Where and WhereDocument filters
FilterIDOp // ID filter
ProjectOp // Field projection (Include)
LimitAndOffsetOp // Pagination
SortOp // Ordering (not yet supported)
ResourceOperation `json:"-"`
}
CollectionGetOp represents a Get operation on a collection.
Use NewCollectionGetOp to create instances, or pass options directly to [Collection.Get].
// Using Collection.Get (recommended)
results, err := collection.Get(ctx,
WithIDs("doc1", "doc2"),
WithInclude(IncludeDocuments),
)
// Using NewCollectionGetOp (advanced)
op, err := NewCollectionGetOp(
WithIDs("doc1", "doc2"),
WithInclude(IncludeDocuments),
)
func NewCollectionGetOp ¶
func NewCollectionGetOp(opts ...GetOption) (*CollectionGetOp, error)
NewCollectionGetOp creates a new Get operation with the given options.
This is primarily for advanced use cases. Most users should use [Collection.Get] directly.
func (*CollectionGetOp) MarshalJSON ¶
func (c *CollectionGetOp) MarshalJSON() ([]byte, error)
func (*CollectionGetOp) Operation ¶
func (c *CollectionGetOp) Operation() OperationType
func (*CollectionGetOp) PrepareAndValidate ¶
func (c *CollectionGetOp) PrepareAndValidate() error
func (*CollectionGetOp) Resource ¶
func (c *CollectionGetOp) Resource() Resource
func (*CollectionGetOp) UnmarshalJSON ¶
func (c *CollectionGetOp) UnmarshalJSON(b []byte) error
type CollectionGetOption ¶
type CollectionGetOption = GetOption
CollectionGetOption is an alias for GetOption for backward compatibility.
type CollectionImpl ¶
type CollectionImpl struct {
// contains filtered or unexported fields
}
func (*CollectionImpl) Add ¶
func (c *CollectionImpl) Add(ctx context.Context, opts ...CollectionAddOption) error
func (*CollectionImpl) Close ¶
func (c *CollectionImpl) Close() error
func (*CollectionImpl) Configuration ¶
func (c *CollectionImpl) Configuration() CollectionConfiguration
func (*CollectionImpl) Database ¶
func (c *CollectionImpl) Database() Database
func (*CollectionImpl) Delete ¶
func (c *CollectionImpl) Delete(ctx context.Context, opts ...CollectionDeleteOption) error
func (*CollectionImpl) Dimension ¶ added in v0.2.3
func (c *CollectionImpl) Dimension() int
func (*CollectionImpl) Fork ¶ added in v0.2.4
func (c *CollectionImpl) Fork(ctx context.Context, newName string) (Collection, error)
func (*CollectionImpl) Get ¶
func (c *CollectionImpl) Get(ctx context.Context, opts ...CollectionGetOption) (GetResult, error)
func (*CollectionImpl) ID ¶
func (c *CollectionImpl) ID() string
func (*CollectionImpl) IndexingStatus ¶ added in v0.3.1
func (c *CollectionImpl) IndexingStatus(ctx context.Context) (*IndexingStatus, error)
func (*CollectionImpl) Metadata ¶
func (c *CollectionImpl) Metadata() CollectionMetadata
func (*CollectionImpl) ModifyConfiguration ¶
func (c *CollectionImpl) ModifyConfiguration(ctx context.Context, newConfig *UpdateCollectionConfiguration) error
func (*CollectionImpl) ModifyMetadata ¶
func (c *CollectionImpl) ModifyMetadata(ctx context.Context, newMetadata CollectionMetadata) error
func (*CollectionImpl) ModifyName ¶
func (c *CollectionImpl) ModifyName(ctx context.Context, newName string) error
func (*CollectionImpl) Name ¶
func (c *CollectionImpl) Name() string
func (*CollectionImpl) Query ¶
func (c *CollectionImpl) Query(ctx context.Context, opts ...CollectionQueryOption) (QueryResult, error)
func (*CollectionImpl) Schema ¶ added in v0.3.0
func (c *CollectionImpl) Schema() *Schema
func (*CollectionImpl) Search ¶ added in v0.3.0
func (c *CollectionImpl) Search(ctx context.Context, opts ...SearchCollectionOption) (SearchResult, error)
func (*CollectionImpl) Tenant ¶
func (c *CollectionImpl) Tenant() Tenant
func (*CollectionImpl) Update ¶
func (c *CollectionImpl) Update(ctx context.Context, opts ...CollectionUpdateOption) error
func (*CollectionImpl) Upsert ¶
func (c *CollectionImpl) Upsert(ctx context.Context, opts ...CollectionAddOption) error
type CollectionLifecycleOp ¶
type CollectionLifecycleOp interface {
PrepareAndValidateCollectionRequest() error
}
type CollectionMetadata ¶
type CollectionMetadata interface {
Keys() []string
GetRaw(key string) (interface{}, bool)
GetString(key string) (string, bool)
GetInt(key string) (int64, bool)
GetFloat(key string) (float64, bool)
GetBool(key string) (bool, bool)
GetStringArray(key string) ([]string, bool)
GetIntArray(key string) ([]int64, bool)
GetFloatArray(key string) ([]float64, bool)
GetBoolArray(key string) ([]bool, bool)
SetRaw(key string, value interface{})
SetString(key, value string)
SetInt(key string, value int64)
SetFloat(key string, value float64)
SetBool(key string, value bool)
SetStringArray(key string, value []string)
SetIntArray(key string, value []int64)
SetFloatArray(key string, value []float64)
SetBoolArray(key string, value []bool)
MarshalJSON() ([]byte, error)
UnmarshalJSON(b []byte) error
}
func NewEmptyMetadata ¶
func NewEmptyMetadata() CollectionMetadata
func NewMetadata ¶
func NewMetadata(attributes ...*MetaAttribute) CollectionMetadata
func NewMetadataFromMap ¶
func NewMetadataFromMap(metadata map[string]interface{}) CollectionMetadata
NewMetadataFromMap converts map values into collection metadata.
For backward compatibility this function uses best-effort conversion and silently skips unsupported values. In particular, invalid []interface{} arrays (mixed types, empty arrays, nested arrays, unsupported element types, and conversion failures) are omitted without returning an error.
Use NewMetadataFromMapStrict when you need error-returning behavior.
func NewMetadataFromMapStrict ¶ added in v0.3.5
func NewMetadataFromMapStrict(metadata map[string]interface{}) (CollectionMetadata, error)
NewMetadataFromMapStrict converts map values into collection metadata.
Unlike NewMetadataFromMap, this function returns an error for unsupported values and invalid []interface{} arrays.
type CollectionMetadataImpl ¶
type CollectionMetadataImpl struct {
// contains filtered or unexported fields
}
Collection metadata
func (*CollectionMetadataImpl) GetBool ¶
func (cm *CollectionMetadataImpl) GetBool(key string) (value bool, ok bool)
func (*CollectionMetadataImpl) GetBoolArray ¶ added in v0.3.5
func (cm *CollectionMetadataImpl) GetBoolArray(key string) ([]bool, bool)
func (*CollectionMetadataImpl) GetFloat ¶
func (cm *CollectionMetadataImpl) GetFloat(key string) (value float64, ok bool)
func (*CollectionMetadataImpl) GetFloatArray ¶ added in v0.3.5
func (cm *CollectionMetadataImpl) GetFloatArray(key string) ([]float64, bool)
func (*CollectionMetadataImpl) GetInt ¶
func (cm *CollectionMetadataImpl) GetInt(key string) (value int64, ok bool)
func (*CollectionMetadataImpl) GetIntArray ¶ added in v0.3.5
func (cm *CollectionMetadataImpl) GetIntArray(key string) ([]int64, bool)
func (*CollectionMetadataImpl) GetRaw ¶
func (cm *CollectionMetadataImpl) GetRaw(key string) (value interface{}, ok bool)
func (*CollectionMetadataImpl) GetString ¶
func (cm *CollectionMetadataImpl) GetString(key string) (value string, ok bool)
func (*CollectionMetadataImpl) GetStringArray ¶ added in v0.3.5
func (cm *CollectionMetadataImpl) GetStringArray(key string) ([]string, bool)
func (*CollectionMetadataImpl) Keys ¶
func (cm *CollectionMetadataImpl) Keys() []string
func (*CollectionMetadataImpl) MarshalJSON ¶
func (cm *CollectionMetadataImpl) MarshalJSON() ([]byte, error)
func (*CollectionMetadataImpl) SetBool ¶
func (cm *CollectionMetadataImpl) SetBool(key string, value bool)
func (*CollectionMetadataImpl) SetBoolArray ¶ added in v0.3.5
func (cm *CollectionMetadataImpl) SetBoolArray(key string, value []bool)
func (*CollectionMetadataImpl) SetFloat ¶
func (cm *CollectionMetadataImpl) SetFloat(key string, value float64)
func (*CollectionMetadataImpl) SetFloatArray ¶ added in v0.3.5
func (cm *CollectionMetadataImpl) SetFloatArray(key string, value []float64)
func (*CollectionMetadataImpl) SetInt ¶
func (cm *CollectionMetadataImpl) SetInt(key string, value int64)
func (*CollectionMetadataImpl) SetIntArray ¶ added in v0.3.5
func (cm *CollectionMetadataImpl) SetIntArray(key string, value []int64)
func (*CollectionMetadataImpl) SetRaw ¶
func (cm *CollectionMetadataImpl) SetRaw(key string, value interface{})
func (*CollectionMetadataImpl) SetString ¶
func (cm *CollectionMetadataImpl) SetString(key, value string)
func (*CollectionMetadataImpl) SetStringArray ¶ added in v0.3.5
func (cm *CollectionMetadataImpl) SetStringArray(key string, value []string)
func (*CollectionMetadataImpl) UnmarshalJSON ¶
func (cm *CollectionMetadataImpl) UnmarshalJSON(b []byte) error
type CollectionModel ¶
type CollectionModel struct {
ID string `json:"id"`
Name string `json:"name"`
ConfigurationJSON map[string]interface{} `json:"configuration_json,omitempty"`
Metadata CollectionMetadata `json:"metadata,omitempty"`
Dimension int `json:"dimension,omitempty"`
Tenant string `json:"tenant,omitempty"`
Database string `json:"database,omitempty"`
Version int `json:"version,omitempty"`
LogPosition int `json:"log_position,omitempty"`
Schema *Schema `json:"schema,omitempty"`
}
func (*CollectionModel) MarshalJSON ¶
func (op *CollectionModel) MarshalJSON() ([]byte, error)
func (*CollectionModel) UnmarshalJSON ¶
func (op *CollectionModel) UnmarshalJSON(b []byte) error
type CollectionOp ¶
type CollectionOp interface {
// PrepareAndValidate validates the operation before sending.
PrepareAndValidate() error
// EmbedData embeds text data using the provided embedding function.
EmbedData(ctx context.Context, ef embeddings.EmbeddingFunction) error
// MarshalJSON serializes the operation to JSON.
MarshalJSON() ([]byte, error)
// UnmarshalJSON deserializes the operation from JSON.
UnmarshalJSON(b []byte) error
}
CollectionOp is the interface for all collection operations. This is an internal interface used by the HTTP client implementation.
type CollectionQueryOp ¶
type CollectionQueryOp struct {
FilterOp // Where and WhereDocument filters
FilterEmbeddingsOp // Pre-computed query embeddings
FilterTextsOp // Query texts to be embedded
LimitResultOp // Number of results per query
ProjectOp // Field projection (Include)
FilterIDOp // Limit search to specific IDs
}
CollectionQueryOp represents a semantic search Query operation.
Use [Collection.Query] with options like WithQueryTexts or WithQueryEmbeddings.
results, err := collection.Query(ctx,
WithQueryTexts("machine learning"),
WithNResults(10),
WithWhere(EqString("status", "published")),
)
func NewCollectionQueryOp ¶
func NewCollectionQueryOp(opts ...QueryOption) (*CollectionQueryOp, error)
NewCollectionQueryOp creates a new Query operation with the given options.
Default NResults is 10. This is primarily for advanced use cases. Most users should use [Collection.Query] directly.
func (*CollectionQueryOp) EmbedData ¶
func (c *CollectionQueryOp) EmbedData(ctx context.Context, ef embeddings.EmbeddingFunction) error
func (*CollectionQueryOp) MarshalJSON ¶
func (c *CollectionQueryOp) MarshalJSON() ([]byte, error)
func (*CollectionQueryOp) Operation ¶
func (c *CollectionQueryOp) Operation() OperationType
func (*CollectionQueryOp) PrepareAndValidate ¶
func (c *CollectionQueryOp) PrepareAndValidate() error
func (*CollectionQueryOp) Resource ¶
func (c *CollectionQueryOp) Resource() Resource
func (*CollectionQueryOp) UnmarshalJSON ¶
func (c *CollectionQueryOp) UnmarshalJSON(b []byte) error
type CollectionQueryOption ¶
type CollectionQueryOption = QueryOption
CollectionQueryOption is an alias for QueryOption for backward compatibility.
type CollectionUpdateOp ¶
type CollectionUpdateOp struct {
// Ids identifies the documents to update (required).
Ids []DocumentID `json:"ids"`
// Documents contain updated text content.
Documents []Document `json:"documents,omitempty"`
// Metadatas contain updated metadata values.
Metadatas []DocumentMetadata `json:"metadatas,omitempty"`
// Embeddings contain updated vector representations.
Embeddings []any `json:"embeddings"`
// Records is an alternative to separate fields.
Records []Record `json:"-"`
}
CollectionUpdateOp represents an Update operation on existing documents.
Use [Collection.Update] with options to modify existing documents:
err := collection.Update(ctx,
WithIDs("doc1"),
WithTexts("Updated document content"),
WithMetadatas(updatedMeta),
)
func NewCollectionUpdateOp ¶
func NewCollectionUpdateOp(opts ...UpdateOption) (*CollectionUpdateOp, error)
NewCollectionUpdateOp creates a new Update operation with the given options.
This is primarily for advanced use cases. Most users should use [Collection.Update] directly.
func (*CollectionUpdateOp) EmbedData ¶
func (c *CollectionUpdateOp) EmbedData(ctx context.Context, ef embeddings.EmbeddingFunction) error
func (*CollectionUpdateOp) MarshalJSON ¶
func (c *CollectionUpdateOp) MarshalJSON() ([]byte, error)
func (*CollectionUpdateOp) Operation ¶
func (c *CollectionUpdateOp) Operation() OperationType
func (*CollectionUpdateOp) PrepareAndValidate ¶
func (c *CollectionUpdateOp) PrepareAndValidate() error
func (*CollectionUpdateOp) Resource ¶
func (c *CollectionUpdateOp) Resource() Resource
func (*CollectionUpdateOp) UnmarshalJSON ¶
func (c *CollectionUpdateOp) UnmarshalJSON(b []byte) error
type CollectionUpdateOption ¶
type CollectionUpdateOption = UpdateOption
CollectionUpdateOption is an alias for UpdateOption for backward compatibility.
type CountCollectionsOp ¶
type CountCollectionsOp struct {
Database Database `json:"-"`
}
func NewCountCollectionsOp ¶
func NewCountCollectionsOp(opts ...CountCollectionsOption) (*CountCollectionsOp, error)
func (*CountCollectionsOp) Operation ¶
func (op *CountCollectionsOp) Operation() OperationType
func (*CountCollectionsOp) PrepareAndValidateCollectionRequest ¶
func (op *CountCollectionsOp) PrepareAndValidateCollectionRequest() error
func (*CountCollectionsOp) Resource ¶
func (op *CountCollectionsOp) Resource() Resource
type CountCollectionsOption ¶
type CountCollectionsOption func(*CountCollectionsOp) error
func WithDatabaseCount ¶
func WithDatabaseCount(database Database) CountCollectionsOption
type CreateCollectionOp ¶
type CreateCollectionOp struct {
Name string `json:"name"`
CreateIfNotExists bool `json:"get_or_create,omitempty"`
Metadata CollectionMetadata `json:"metadata,omitempty"`
Configuration *CollectionConfigurationImpl `json:"configuration,omitempty"`
Schema *Schema `json:"schema,omitempty"`
Database Database `json:"-"`
// contains filtered or unexported fields
}
func NewCreateCollectionOp ¶
func NewCreateCollectionOp(name string, opts ...CreateCollectionOption) (*CreateCollectionOp, error)
func (*CreateCollectionOp) MarshalJSON ¶
func (op *CreateCollectionOp) MarshalJSON() ([]byte, error)
func (*CreateCollectionOp) Operation ¶
func (op *CreateCollectionOp) Operation() OperationType
func (*CreateCollectionOp) PrepareAndValidateCollectionRequest ¶
func (op *CreateCollectionOp) PrepareAndValidateCollectionRequest() error
func (*CreateCollectionOp) Resource ¶
func (op *CreateCollectionOp) Resource() Resource
func (*CreateCollectionOp) String ¶
func (op *CreateCollectionOp) String() string
func (*CreateCollectionOp) UnmarshalJSON ¶
func (op *CreateCollectionOp) UnmarshalJSON(b []byte) error
type CreateCollectionOption ¶
type CreateCollectionOption func(*CreateCollectionOp) error
func WithCollectionMetadataCreate ¶
func WithCollectionMetadataCreate(metadata CollectionMetadata) CreateCollectionOption
func WithCollectionMetadataMapCreateStrict ¶ added in v0.3.5
func WithCollectionMetadataMapCreateStrict(metadata map[string]interface{}) CreateCollectionOption
WithCollectionMetadataMapCreateStrict converts metadata from a raw map using strict validation. Invalid metadata causes collection operations to fail before any HTTP request is sent.
func WithConfigurationCreate ¶ added in v0.3.0
func WithConfigurationCreate(config *CollectionConfigurationImpl) CreateCollectionOption
WithConfigurationCreate sets the complete configuration for the collection
func WithDatabaseCreate ¶
func WithDatabaseCreate(database Database) CreateCollectionOption
WithDatabaseCreate allows the creation of a collection in a specific database, different from the default one set at Client level.
func WithDisableEFConfigStorage ¶ added in v0.3.0
func WithDisableEFConfigStorage() CreateCollectionOption
WithDisableEFConfigStorage disables storing embedding function configuration in the collection's server-side configuration. Use this when connecting to Chroma versions prior to 1.0.0 that don't support configuration.embedding_function.
func WithEmbeddingFunctionCreate ¶
func WithEmbeddingFunctionCreate(embeddingFunction embeddings.EmbeddingFunction) CreateCollectionOption
func WithFtsIndexCreate ¶ added in v0.3.0
func WithFtsIndexCreate(config *FtsIndexConfig) CreateCollectionOption
WithFtsIndexCreate adds a full-text search index configuration to the collection schema. If a schema already exists on the operation, the FTS index is merged into it.
func WithHNSWBatchSizeCreate ¶
func WithHNSWBatchSizeCreate(batchSize int) CreateCollectionOption
func WithHNSWConstructionEfCreate ¶
func WithHNSWConstructionEfCreate(efConstruction int) CreateCollectionOption
func WithHNSWMCreate ¶
func WithHNSWMCreate(m int) CreateCollectionOption
func WithHNSWNumThreadsCreate ¶
func WithHNSWNumThreadsCreate(numThreads int) CreateCollectionOption
func WithHNSWResizeFactorCreate ¶
func WithHNSWResizeFactorCreate(resizeFactor float64) CreateCollectionOption
func WithHNSWSearchEfCreate ¶
func WithHNSWSearchEfCreate(efSearch int) CreateCollectionOption
func WithHNSWSpaceCreate ¶
func WithHNSWSpaceCreate(metric embeddings.DistanceMetric) CreateCollectionOption
func WithHNSWSyncThresholdCreate ¶
func WithHNSWSyncThresholdCreate(syncThreshold int) CreateCollectionOption
func WithIfNotExistsCreate ¶
func WithIfNotExistsCreate() CreateCollectionOption
func WithSchemaCreate ¶ added in v0.3.0
func WithSchemaCreate(schema *Schema) CreateCollectionOption
WithSchemaCreate sets the schema for the collection
func WithVectorIndexCreate ¶ added in v0.3.0
func WithVectorIndexCreate(config *VectorIndexConfig) CreateCollectionOption
WithVectorIndexCreate adds a vector index configuration to the collection schema. If a schema already exists on the operation, the vector index is merged into it.
type CredentialsProvider ¶
type Database ¶
type Database interface {
ID() string
Name() string
Tenant() Tenant
String() string
Validate() error
}
func NewDatabase ¶
func NewDatabaseFromJSON ¶
func NewDatabaseFromMap ¶
func NewDefaultDatabase ¶
func NewDefaultDatabase() Database
type DatabaseBase ¶
type DatabaseBase struct {
DBName string `json:"name" mapstructure:"name"`
DBID string `json:"id,omitempty" mapstructure:"id"`
TenantName string `json:"tenant,omitempty" mapstructure:"tenant"`
// contains filtered or unexported fields
}
func (DatabaseBase) ID ¶
func (d DatabaseBase) ID() string
func (DatabaseBase) Name ¶
func (d DatabaseBase) Name() string
func (DatabaseBase) String ¶
func (d DatabaseBase) String() string
func (DatabaseBase) Tenant ¶
func (d DatabaseBase) Tenant() Tenant
func (DatabaseBase) Validate ¶
func (d DatabaseBase) Validate() error
type DeleteCollectionOp ¶
type DeleteCollectionOp struct {
Database Database `json:"-"`
}
func NewDeleteCollectionOp ¶
func NewDeleteCollectionOp(opts ...DeleteCollectionOption) (*DeleteCollectionOp, error)
func (*DeleteCollectionOp) Operation ¶
func (op *DeleteCollectionOp) Operation() OperationType
func (*DeleteCollectionOp) PrepareAndValidateCollectionRequest ¶
func (op *DeleteCollectionOp) PrepareAndValidateCollectionRequest() error
func (*DeleteCollectionOp) Resource ¶
func (op *DeleteCollectionOp) Resource() Resource
type DeleteCollectionOption ¶
type DeleteCollectionOption func(*DeleteCollectionOp) error
func WithDatabaseDelete ¶
func WithDatabaseDelete(database Database) DeleteCollectionOption
type DeleteOption ¶ added in v0.3.2
type DeleteOption interface {
ApplyToDelete(*CollectionDeleteOp) error
}
DeleteOption configures a [Collection.Delete] operation. Implementations include WithIDs, WithWhere, and WithWhereDocument. At least one filter option must be provided.
func WithIDsDelete
deprecated
func WithIDsDelete(ids ...DocumentID) DeleteOption
Deprecated: Use WithIDs instead.
func WithWhereDelete
deprecated
func WithWhereDelete(where WhereFilter) DeleteOption
Deprecated: Use WithWhere instead.
func WithWhereDocumentDelete
deprecated
func WithWhereDocumentDelete(whereDocument WhereDocumentFilter) DeleteOption
Deprecated: Use WithWhereDocument instead.
type DeleteOptionFunc ¶ added in v0.3.2
type DeleteOptionFunc func(*CollectionDeleteOp) error
DeleteOptionFunc wraps a function as a DeleteOption. Use this to create custom Delete options without defining a new type.
func (DeleteOptionFunc) ApplyToDelete ¶ added in v0.3.2
func (f DeleteOptionFunc) ApplyToDelete(op *CollectionDeleteOp) error
ApplyToDelete implements DeleteOption.
type DivRank ¶ added in v0.3.0
type DivRank struct {
// contains filtered or unexported fields
}
DivRank represents division of two rank expressions. Serializes to JSON as {"$div": {"left": ..., "right": ...}}.
NOTE: Division by zero validation only catches literal zero denominators (Val(0)). Complex expressions that evaluate to zero at runtime (e.g., Val(1).Sub(Val(1))) will produce Inf/NaN on the server following NumPy semantics. Use epsilon values when dividing by potentially zero expressions.
func (*DivRank) MarshalJSON ¶ added in v0.3.0
func (*DivRank) UnmarshalJSON ¶ added in v0.3.0
type DocumentID ¶
type DocumentID string
type DocumentIDs ¶
type DocumentIDs []DocumentID
type DocumentMetadata ¶
type DocumentMetadata interface {
GetRaw(key string) (interface{}, bool)
GetString(key string) (string, bool)
GetInt(key string) (int64, bool)
GetFloat(key string) (float64, bool)
GetBool(key string) (bool, bool)
GetStringArray(key string) ([]string, bool)
GetIntArray(key string) ([]int64, bool)
GetFloatArray(key string) ([]float64, bool)
GetBoolArray(key string) ([]bool, bool)
SetRaw(key string, value interface{})
SetString(key, value string)
SetInt(key string, value int64)
SetFloat(key string, value float64)
SetBool(key string, value bool)
SetStringArray(key string, value []string)
SetIntArray(key string, value []int64)
SetFloatArray(key string, value []float64)
SetBoolArray(key string, value []bool)
}
func NewDocumentMetadata ¶
func NewDocumentMetadata(attributes ...*MetaAttribute) DocumentMetadata
func NewDocumentMetadataFromMap ¶
func NewDocumentMetadataFromMap(metadata map[string]interface{}) (DocumentMetadata, error)
type DocumentMetadataImpl ¶
type DocumentMetadataImpl struct {
// contains filtered or unexported fields
}
func (*DocumentMetadataImpl) GetBool ¶
func (cm *DocumentMetadataImpl) GetBool(key string) (value bool, ok bool)
func (*DocumentMetadataImpl) GetBoolArray ¶ added in v0.3.5
func (cm *DocumentMetadataImpl) GetBoolArray(key string) ([]bool, bool)
func (*DocumentMetadataImpl) GetFloat ¶
func (cm *DocumentMetadataImpl) GetFloat(key string) (value float64, ok bool)
func (*DocumentMetadataImpl) GetFloatArray ¶ added in v0.3.5
func (cm *DocumentMetadataImpl) GetFloatArray(key string) ([]float64, bool)
func (*DocumentMetadataImpl) GetInt ¶
func (cm *DocumentMetadataImpl) GetInt(key string) (value int64, ok bool)
func (*DocumentMetadataImpl) GetIntArray ¶ added in v0.3.5
func (cm *DocumentMetadataImpl) GetIntArray(key string) ([]int64, bool)
func (*DocumentMetadataImpl) GetRaw ¶
func (cm *DocumentMetadataImpl) GetRaw(key string) (value interface{}, ok bool)
func (*DocumentMetadataImpl) GetString ¶
func (cm *DocumentMetadataImpl) GetString(key string) (value string, ok bool)
func (*DocumentMetadataImpl) GetStringArray ¶ added in v0.3.5
func (cm *DocumentMetadataImpl) GetStringArray(key string) ([]string, bool)
func (*DocumentMetadataImpl) Keys ¶
func (cm *DocumentMetadataImpl) Keys() []string
func (*DocumentMetadataImpl) MarshalJSON ¶
func (cm *DocumentMetadataImpl) MarshalJSON() ([]byte, error)
func (*DocumentMetadataImpl) SetBool ¶
func (cm *DocumentMetadataImpl) SetBool(key string, value bool)
func (*DocumentMetadataImpl) SetBoolArray ¶ added in v0.3.5
func (cm *DocumentMetadataImpl) SetBoolArray(key string, value []bool)
func (*DocumentMetadataImpl) SetFloat ¶
func (cm *DocumentMetadataImpl) SetFloat(key string, value float64)
func (*DocumentMetadataImpl) SetFloatArray ¶ added in v0.3.5
func (cm *DocumentMetadataImpl) SetFloatArray(key string, value []float64)
func (*DocumentMetadataImpl) SetInt ¶
func (cm *DocumentMetadataImpl) SetInt(key string, value int64)
func (*DocumentMetadataImpl) SetIntArray ¶ added in v0.3.5
func (cm *DocumentMetadataImpl) SetIntArray(key string, value []int64)
func (*DocumentMetadataImpl) SetRaw ¶
func (cm *DocumentMetadataImpl) SetRaw(key string, value interface{})
func (*DocumentMetadataImpl) SetString ¶
func (cm *DocumentMetadataImpl) SetString(key, value string)
func (*DocumentMetadataImpl) SetStringArray ¶ added in v0.3.5
func (cm *DocumentMetadataImpl) SetStringArray(key string, value []string)
func (*DocumentMetadataImpl) UnmarshalJSON ¶
func (cm *DocumentMetadataImpl) UnmarshalJSON(b []byte) error
type DocumentMetadatas ¶
type DocumentMetadatas []DocumentMetadata
type EmbeddingFunctionInfo ¶ added in v0.3.0
type EmbeddingFunctionInfo struct {
Type string `json:"type"`
Name string `json:"name"`
Config map[string]interface{} `json:"config"`
}
EmbeddingFunctionInfo represents the embedding function configuration stored in collection configuration
func (*EmbeddingFunctionInfo) IsKnown ¶ added in v0.3.0
func (e *EmbeddingFunctionInfo) IsKnown() bool
IsKnown returns true if the embedding function type is "known" and can be reconstructed
type ExpRank ¶ added in v0.3.0
type ExpRank struct {
// contains filtered or unexported fields
}
ExpRank represents the exponential (e^x) of a rank expression. Serializes to JSON as {"$exp": <rank>}.
func (*ExpRank) MarshalJSON ¶ added in v0.3.0
func (*ExpRank) UnmarshalJSON ¶ added in v0.3.0
type FilterEmbeddingsOp ¶
type FilterEmbeddingsOp struct {
QueryEmbeddings []embeddings.Embedding `json:"query_embeddings"`
}
FilterEmbeddingsOp holds pre-computed embeddings for semantic search.
type FilterIDOp ¶
type FilterIDOp struct {
// Ids contains the document IDs to filter by.
Ids []DocumentID `json:"ids,omitempty"`
}
FilterIDOp provides ID-based filtering capabilities. Embedded in operations that support filtering by document IDs.
func (*FilterIDOp) AppendIDs ¶ added in v0.3.2
func (f *FilterIDOp) AppendIDs(ids ...DocumentID)
AppendIDs adds document IDs to the filter.
type FilterOp ¶
type FilterOp struct {
// Where filters by metadata field values.
Where WhereFilter `json:"where,omitempty"`
// WhereDocument filters by document text content.
WhereDocument WhereDocumentFilter `json:"where_document,omitempty"`
}
FilterOp provides metadata and document content filtering capabilities. Embedded in operations that support Where and WhereDocument filters.
func (*FilterOp) SetWhere ¶ added in v0.3.2
func (f *FilterOp) SetWhere(where WhereFilter)
SetWhere sets the metadata filter.
func (*FilterOp) SetWhereDocument ¶ added in v0.3.2
func (f *FilterOp) SetWhereDocument(where WhereDocumentFilter)
SetWhereDocument sets the document content filter.
type FilterTextsOp ¶
type FilterTextsOp struct {
QueryTexts []string `json:"-"`
}
FilterTextsOp holds query texts for semantic search. The texts are embedded before search.
type FloatInvertedIndexConfig ¶ added in v0.3.0
type FloatInvertedIndexConfig struct{}
type FloatInvertedIndexType ¶ added in v0.3.0
type FloatInvertedIndexType struct {
Enabled bool `json:"enabled"`
Config *FloatInvertedIndexConfig `json:"config,omitempty"`
}
FloatInvertedIndexType wraps FloatInvertedIndexConfig with enabled state
type FloatListValueType ¶ added in v0.3.0
type FloatListValueType struct {
VectorIndex *VectorIndexType `json:"vector_index,omitempty"`
}
FloatListValueType defines indexes for dense vectors
type FloatOperand ¶ added in v0.3.0
type FloatOperand float64
FloatOperand wraps a float for use in rank arithmetic expressions.
Example:
rank := NewKnnRank(KnnQueryText("query")).Multiply(FloatOperand(0.7))
func (FloatOperand) IsOperand ¶ added in v0.3.0
func (f FloatOperand) IsOperand()
type FloatValueType ¶ added in v0.3.0
type FloatValueType struct {
FloatInvertedIndex *FloatInvertedIndexType `json:"float_inverted_index,omitempty"`
}
FloatValueType defines indexes for float metadata
type FtsIndexConfig ¶ added in v0.3.0
type FtsIndexConfig struct{}
FtsIndexConfig represents Full-Text Search index configuration
type FtsIndexType ¶ added in v0.3.0
type FtsIndexType struct {
Enabled bool `json:"enabled"`
Config *FtsIndexConfig `json:"config,omitempty"`
}
FtsIndexType wraps FtsIndexConfig with enabled state
type GenerateOptions ¶
type GenerateOptions struct {
Document string
}
type GetCollectionOp ¶
type GetCollectionOp struct {
Database Database `json:"-"`
// contains filtered or unexported fields
}
func NewGetCollectionOp ¶
func NewGetCollectionOp(opts ...GetCollectionOption) (*GetCollectionOp, error)
func (*GetCollectionOp) Operation ¶
func (op *GetCollectionOp) Operation() OperationType
func (*GetCollectionOp) PrepareAndValidateCollectionRequest ¶
func (op *GetCollectionOp) PrepareAndValidateCollectionRequest() error
func (*GetCollectionOp) Resource ¶
func (op *GetCollectionOp) Resource() Resource
type GetCollectionOption ¶
type GetCollectionOption func(*GetCollectionOp) error
func WithCollectionNameGet ¶ added in v0.2.3
func WithCollectionNameGet(name string) GetCollectionOption
func WithDatabaseGet ¶
func WithDatabaseGet(database Database) GetCollectionOption
func WithEmbeddingFunctionGet ¶
func WithEmbeddingFunctionGet(embeddingFunction embeddings.EmbeddingFunction) GetCollectionOption
type GetOption ¶ added in v0.3.2
type GetOption interface {
ApplyToGet(*CollectionGetOp) error
}
GetOption configures a [Collection.Get] operation. Implementations include WithIDs, WithWhere, WithWhereDocument, WithInclude, WithLimit, and WithOffset.
func WithIDsGet
deprecated
func WithIDsGet(ids ...DocumentID) GetOption
Deprecated: Use WithIDs instead.
func WithIncludeGet
deprecated
Deprecated: Use WithInclude instead.
func WithLimitGet
deprecated
func WithOffsetGet
deprecated
Deprecated: Use WithOffset instead.
func WithWhereDocumentGet
deprecated
func WithWhereDocumentGet(whereDocument WhereDocumentFilter) GetOption
Deprecated: Use WithWhereDocument instead.
func WithWhereGet
deprecated
func WithWhereGet(where WhereFilter) GetOption
Deprecated: Use WithWhere instead.
type GetOptionFunc ¶ added in v0.3.2
type GetOptionFunc func(*CollectionGetOp) error
GetOptionFunc wraps a function as a GetOption. Use this to create custom Get options without defining a new type.
customOpt := GetOptionFunc(func(op *CollectionGetOp) error {
op.Limit = 50
return nil
})
func (GetOptionFunc) ApplyToGet ¶ added in v0.3.2
func (f GetOptionFunc) ApplyToGet(op *CollectionGetOp) error
ApplyToGet implements GetOption.
type GetResult ¶
type GetResult interface {
// GetIDs returns the IDs of the documents in the result.
GetIDs() DocumentIDs
// GetDocuments returns the documents in the result.
GetDocuments() Documents
// GetMetadatas returns the metadatas of the documents in the result.
GetMetadatas() DocumentMetadatas
// GetEmbeddings returns the embeddings of the documents in the result.
GetEmbeddings() embeddings.Embeddings
// ToRecords converts the result to a Records object.
ToRecords() Records
// Count returns the number of documents in the result.
Count() int
// Next when using limint and offset, this will return the next page of results
Next() (GetResult, error)
}
type GetResultImpl ¶
type GetResultImpl struct {
Ids DocumentIDs `json:"ids,omitempty"`
Documents Documents `json:"documents,omitempty"`
Metadatas DocumentMetadatas `json:"metadatas,omitempty"`
Embeddings embeddings.Embeddings `json:"embeddings,omitempty"`
Include []Include `json:"include,omitempty"`
}
func (*GetResultImpl) At ¶ added in v0.3.0
func (r *GetResultImpl) At(index int) (ResultRow, bool)
At returns the result at the given index with bounds checking. Returns false if index is out of bounds.
func (*GetResultImpl) Count ¶
func (r *GetResultImpl) Count() int
func (*GetResultImpl) GetDocuments ¶
func (r *GetResultImpl) GetDocuments() Documents
func (*GetResultImpl) GetEmbeddings ¶
func (r *GetResultImpl) GetEmbeddings() embeddings.Embeddings
func (*GetResultImpl) GetIDs ¶
func (r *GetResultImpl) GetIDs() DocumentIDs
func (*GetResultImpl) GetMetadatas ¶
func (r *GetResultImpl) GetMetadatas() DocumentMetadatas
func (*GetResultImpl) Next ¶
func (r *GetResultImpl) Next() (GetResult, error)
func (*GetResultImpl) Rows ¶ added in v0.3.0
func (r *GetResultImpl) Rows() []ResultRow
Rows returns all results as ResultRow slice for easy iteration.
func (*GetResultImpl) String ¶ added in v0.2.1
func (r *GetResultImpl) String() string
func (*GetResultImpl) ToRecords ¶
func (r *GetResultImpl) ToRecords() Records
func (*GetResultImpl) UnmarshalJSON ¶
func (r *GetResultImpl) UnmarshalJSON(data []byte) error
type GroupBy ¶ added in v0.3.0
GroupBy groups search results by metadata keys and aggregates within groups.
func NewGroupBy ¶ added in v0.3.0
NewGroupBy creates a GroupBy that partitions results by metadata keys.
Example:
result, err := collection.Search(ctx,
NewSearchRequest(
WithKnnRank(KnnQueryText("query"), WithKnnLimit(100)),
WithGroupBy(NewGroupBy(NewMinK(3, KScore), K("category"))),
WithPage(WithLimit(30)),
),
)
func (*GroupBy) MarshalJSON ¶ added in v0.3.0
type HnswIndexConfig ¶ added in v0.3.0
type HnswIndexConfig struct {
EfConstruction uint `json:"ef_construction,omitempty" default:"100"`
MaxNeighbors uint `json:"max_neighbors,omitempty" default:"16"`
EfSearch uint `json:"ef_search,omitempty" default:"100"`
NumThreads uint `json:"num_threads,omitempty" default:"1"`
BatchSize uint `json:"batch_size,omitempty" default:"100" validate:"min=2"`
SyncThreshold uint `json:"sync_threshold,omitempty" default:"1000" validate:"min=2"`
ResizeFactor float64 `json:"resize_factor,omitempty" default:"1.2"`
}
HnswIndexConfig represents HNSW algorithm parameters
func NewHnswConfig ¶ added in v0.3.0
func NewHnswConfig(opts ...HnswOption) *HnswIndexConfig
NewHnswConfig creates a new HnswIndexConfig with the given options
func NewHnswConfigWithDefaults ¶ added in v0.3.0
func NewHnswConfigWithDefaults(opts ...HnswOption) (*HnswIndexConfig, error)
NewHnswConfigWithDefaults creates a new HnswIndexConfig with defaults applied and validation
type HnswOption ¶ added in v0.3.0
type HnswOption func(*HnswIndexConfig)
HnswOption configures an HnswIndexConfig
func WithBatchSize ¶ added in v0.3.0
func WithBatchSize(size uint) HnswOption
func WithEfConstruction ¶ added in v0.3.0
func WithEfConstruction(ef uint) HnswOption
func WithEfSearch ¶ added in v0.3.0
func WithEfSearch(ef uint) HnswOption
func WithMaxNeighbors ¶ added in v0.3.0
func WithMaxNeighbors(m uint) HnswOption
func WithNumThreads ¶ added in v0.3.0
func WithNumThreads(n uint) HnswOption
func WithResizeFactor ¶ added in v0.3.0
func WithResizeFactor(factor float64) HnswOption
func WithSyncThreshold ¶ added in v0.3.0
func WithSyncThreshold(threshold uint) HnswOption
type IDGenerator ¶
type IDGenerator interface {
Generate(opts ...IDGeneratorOption) string
}
type IDGeneratorOption ¶
type IDGeneratorOption func(opts *GenerateOptions)
func WithDocument ¶
func WithDocument(document string) IDGeneratorOption
type IndexingStatus ¶ added in v0.3.1
type IndexingStatus struct {
// NumIndexedOps is the number of operations that have been indexed.
NumIndexedOps uint64 `json:"num_indexed_ops"`
// NumUnindexedOps is the number of operations waiting to be indexed.
NumUnindexedOps uint64 `json:"num_unindexed_ops"`
// TotalOps is the total number of operations (indexed + unindexed).
TotalOps uint64 `json:"total_ops"`
// OpIndexingProgress is the indexing progress as a fraction (0.0 to 1.0).
// A value of 1.0 means all operations have been indexed.
OpIndexingProgress float64 `json:"op_indexing_progress"`
}
IndexingStatus represents the current indexing state of a collection.
After adding documents, Chroma indexes them in the background. Use this to monitor indexing progress, especially after bulk inserts.
status, err := collection.IndexingStatus(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Indexing progress: %.1f%%\n", status.OpIndexingProgress*100)
type IntInvertedIndexConfig ¶ added in v0.3.0
type IntInvertedIndexConfig struct{}
type IntInvertedIndexType ¶ added in v0.3.0
type IntInvertedIndexType struct {
Enabled bool `json:"enabled"`
Config *IntInvertedIndexConfig `json:"config,omitempty"`
}
IntInvertedIndexType wraps IntInvertedIndexConfig with enabled state
type IntOperand ¶ added in v0.3.0
type IntOperand int64
IntOperand wraps an integer for use in rank arithmetic expressions.
Example:
rank := Val(1.0).Add(IntOperand(5)) // Produces: {"$sum": [{"$val": 1}, {"$val": 5}]}
func (IntOperand) IsOperand ¶ added in v0.3.0
func (i IntOperand) IsOperand()
type IntValueType ¶ added in v0.3.0
type IntValueType struct {
IntInvertedIndex *IntInvertedIndexType `json:"int_inverted_index,omitempty"`
}
IntValueType defines indexes for integer metadata
type Key ¶ added in v0.3.0
type Key = string
Key identifies a metadata field for filtering or projection in the Search API.
Key is a type alias for string, so raw strings work directly for backward compatibility. Both patterns are valid and compile correctly:
EqString(K("status"), "active") // K() marks field names clearly (recommended for Search API)
EqString("status", "active") // Raw string also works (common in Query API)
The K function is a no-op that returns the string unchanged, serving purely as documentation to distinguish field names from values in filter expressions.
For built-in fields, use the predefined constants: KDocument, KEmbedding, KScore, KMetadata, and KID.
const ( // KDocument represents the document text content. // Use in WithSelect to include document text in results. KDocument Key = "#document" // KEmbedding represents the vector embedding. // Use in WithSelect to include embeddings in results. KEmbedding Key = "#embedding" // KScore represents the ranking/similarity score. // Use in WithSelect to include scores in results. KScore Key = "#score" // KMetadata represents all metadata fields as a map. // Use in WithSelect to include all metadata in results. KMetadata Key = "#metadata" // KID represents the document ID. // Use in WithSelect to include IDs in results (usually included by default). KID Key = "#id" )
Standard keys for document fields in Search API expressions.
Use these constants with WithSelect to specify which fields to include in search results, or with filters to query these fields directly.
func K ¶ added in v0.3.0
K creates a Key for a metadata field name.
Use this to clearly mark field names in filter and projection expressions. This improves code readability by distinguishing field names from values.
K() is a no-op identity function - it returns the string unchanged. Both K("field") and "field" compile to the same value. The function exists solely for documentation purposes.
Filter Example (Search API style with K()) ¶
WithFilter(And(
EqString(K("status"), "published"),
GtInt(K("views"), 1000),
))
Filter Example (Query API style without K()) ¶
WithWhere(AndFilter(
EqString("status", "published"),
GtInt("views", 1000),
))
Projection Example ¶
WithSelect(KDocument, KScore, K("title"), K("author"))
type KnnOption ¶ added in v0.3.0
KnnOption configures optional parameters for KnnRank.
func WithKnnDefault ¶ added in v0.3.0
WithKnnDefault sets the score for documents not in the top-K nearest neighbors. When set, documents outside the KNN results receive this score instead of being excluded. Use this for inclusive multi-query searches where a document should match ANY query.
Example:
rank := NewKnnRank(query, WithKnnDefault(10.0)) // Non-matches get score 10.0
func WithKnnKey ¶ added in v0.3.0
WithKnnKey specifies which embedding field to search. Default is "#embedding" (the main embedding). Use for multi-vector or sparse searches.
Example:
rank := NewKnnRank(query, WithKnnKey(K("sparse_embedding")))
func WithKnnLimit ¶ added in v0.3.0
WithKnnLimit sets the maximum number of nearest neighbors to retrieve. Only the top K documents are scored; others receive the default score or are excluded. Default is 16.
func WithKnnReturnRank ¶ added in v0.3.0
func WithKnnReturnRank() KnnOption
WithKnnReturnRank makes the KNN return rank position (1, 2, 3...) instead of distance. Required when using KnnRank with Reciprocal Rank Fusion (RrfRank).
type KnnQueryOption ¶ added in v0.3.0
KnnQueryOption sets the query for KnnRank.
func KnnQuerySparseVector ¶ added in v0.3.0
func KnnQuerySparseVector(sparseVector *embeddings.SparseVector) KnnQueryOption
KnnQuerySparseVector creates a KNN query from a sparse vector. Use with WithKnnKey to target a sparse embedding field.
Example:
sparse, err := embeddings.NewSparseVector([]int{1, 5, 10}, []float32{0.5, 0.3, 0.8})
if err != nil { return err }
rank, err := NewKnnRank(KnnQuerySparseVector(sparse), WithKnnKey(K("sparse_embedding")))
func KnnQueryText ¶ added in v0.3.0
func KnnQueryText(text string) KnnQueryOption
KnnQueryText creates a KNN query from text that will be auto-embedded. The collection's embedding function will convert the text to a vector at search time.
Example:
rank := NewKnnRank(KnnQueryText("machine learning research"))
func KnnQueryVector ¶ added in v0.3.0
func KnnQueryVector(queryVector embeddings.KnnVector) KnnQueryOption
KnnQueryVector creates a KNN query from a dense vector embedding. The vector will be used directly for similarity search without auto-embedding.
Example:
vector := embeddings.NewEmbeddingFromFloat32([]float32{0.1, 0.2, 0.3, ...})
rank := NewKnnRank(KnnQueryVector(vector))
type KnnRank ¶ added in v0.3.0
KnnRank performs K-Nearest Neighbors search and scoring. Serializes to JSON as {"$knn": {...}}.
Create using NewKnnRank with a query option and optional configuration:
// Text query (auto-embedded)
rank := NewKnnRank(KnnQueryText("search query"))
// With options
rank := NewKnnRank(
KnnQueryText("query"),
WithKnnLimit(100),
WithKnnDefault(10.0),
)
// Weighted combination
combined := rank1.Multiply(FloatOperand(0.7)).Add(rank2.Multiply(FloatOperand(0.3)))
func NewKnnRank ¶ added in v0.3.0
func NewKnnRank(query KnnQueryOption, knnOptions ...KnnOption) (*KnnRank, error)
NewKnnRank creates a K-Nearest Neighbors ranking expression.
Parameters:
- query: The search query (use KnnQueryText, KnnQueryVector, or KnnQuerySparseVector)
- knnOptions: Optional configuration (WithKnnLimit, WithKnnKey, WithKnnDefault, WithKnnReturnRank)
Example:
rank, err := NewKnnRank(
KnnQueryText("machine learning"),
WithKnnLimit(50),
WithKnnDefault(10.0),
)
func (*KnnRank) MarshalJSON ¶ added in v0.3.0
func (*KnnRank) UnmarshalJSON ¶ added in v0.3.0
func (*KnnRank) WithWeight ¶ added in v0.3.0
func (k *KnnRank) WithWeight(weight float64) RankWithWeight
type LimitAndOffsetOp ¶
type LimitAndOffsetOp struct {
Limit int `json:"limit,omitempty"`
Offset int `json:"offset,omitempty"`
}
LimitAndOffsetOp provides pagination for Get operations.
type LimitResultOp ¶
type LimitResultOp struct {
NResults int `json:"n_results"`
}
LimitResultOp specifies the number of results for Query operations.
type ListCollectionOp ¶
type ListCollectionOp struct {
Database Database `json:"-"`
// contains filtered or unexported fields
}
func NewListCollectionsOp ¶
func NewListCollectionsOp(opts ...ListCollectionsOption) (*ListCollectionOp, error)
func (*ListCollectionOp) Limit ¶
func (op *ListCollectionOp) Limit() int
func (*ListCollectionOp) Offset ¶
func (op *ListCollectionOp) Offset() int
func (*ListCollectionOp) Operation ¶
func (op *ListCollectionOp) Operation() OperationType
func (*ListCollectionOp) PrepareAndValidateCollectionRequest ¶
func (op *ListCollectionOp) PrepareAndValidateCollectionRequest() error
func (*ListCollectionOp) Resource ¶
func (op *ListCollectionOp) Resource() Resource
type ListCollectionsOption ¶
type ListCollectionsOption func(*ListCollectionOp) error
func ListWithLimit ¶
func ListWithLimit(limit int) ListCollectionsOption
func ListWithOffset ¶
func ListWithOffset(offset int) ListCollectionsOption
func WithDatabaseList ¶
func WithDatabaseList(database Database) ListCollectionsOption
type LogRank ¶ added in v0.3.0
type LogRank struct {
// contains filtered or unexported fields
}
LogRank represents the natural logarithm of a rank expression. Serializes to JSON as {"$log": <rank>}.
func (*LogRank) MarshalJSON ¶ added in v0.3.0
func (*LogRank) UnmarshalJSON ¶ added in v0.3.0
type MaxK ¶ added in v0.3.0
MaxK selects k records with the largest values (descending order). Use when higher values are better (e.g., ratings, relevance scores).
func NewMaxK ¶ added in v0.3.0
NewMaxK creates a MaxK aggregation that selects k records with largest values.
Example:
NewMaxK(3, K("rating")) // Top 3 highest ratings
NewMaxK(2, K("year"), K("rating")) // With tiebreaker
func (*MaxK) MarshalJSON ¶ added in v0.3.0
type MaxRank ¶ added in v0.3.0
type MaxRank struct {
// contains filtered or unexported fields
}
MaxRank represents the maximum of multiple rank expressions. Serializes to JSON as {"$max": [...]}.
func (*MaxRank) MarshalJSON ¶ added in v0.3.0
func (*MaxRank) UnmarshalJSON ¶ added in v0.3.0
type MetaAttribute ¶
type MetaAttribute struct {
// contains filtered or unexported fields
}
func NewBoolArrayAttribute ¶ added in v0.3.5
func NewBoolArrayAttribute(key string, values []bool) *MetaAttribute
func NewBoolAttribute ¶
func NewBoolAttribute(key string, value bool) *MetaAttribute
func NewFloatArrayAttribute ¶ added in v0.3.5
func NewFloatArrayAttribute(key string, values []float64) *MetaAttribute
func NewFloatAttribute ¶
func NewFloatAttribute(key string, value float64) *MetaAttribute
func NewIntArrayAttribute ¶ added in v0.3.5
func NewIntArrayAttribute(key string, values []int64) *MetaAttribute
func NewIntAttribute ¶
func NewIntAttribute(key string, value int64) *MetaAttribute
func NewStringArrayAttribute ¶ added in v0.3.5
func NewStringArrayAttribute(key string, values []string) *MetaAttribute
func NewStringAttribute ¶
func NewStringAttribute(key string, value string) *MetaAttribute
func RemoveAttribute ¶ added in v0.2.5
func RemoveAttribute(key string) *MetaAttribute
type MetadataValue ¶
type MetadataValue struct {
Bool *bool `json:"-"`
Float64 *float64 `json:"-"`
Int *int64 `json:"-"`
StringValue *string `json:"-"`
NilValue bool `json:"-"`
StringArray []string `json:"-"`
IntArray []int64 `json:"-"`
FloatArray []float64 `json:"-"`
BoolArray []bool `json:"-"`
}
func (*MetadataValue) Equal ¶
func (mv *MetadataValue) Equal(other *MetadataValue) bool
func (*MetadataValue) GetBool ¶
func (mv *MetadataValue) GetBool() (bool, bool)
func (*MetadataValue) GetBoolArray ¶ added in v0.3.5
func (mv *MetadataValue) GetBoolArray() ([]bool, bool)
func (*MetadataValue) GetFloat ¶
func (mv *MetadataValue) GetFloat() (float64, bool)
func (*MetadataValue) GetFloatArray ¶ added in v0.3.5
func (mv *MetadataValue) GetFloatArray() ([]float64, bool)
func (*MetadataValue) GetInt ¶
func (mv *MetadataValue) GetInt() (int64, bool)
func (*MetadataValue) GetIntArray ¶ added in v0.3.5
func (mv *MetadataValue) GetIntArray() ([]int64, bool)
func (*MetadataValue) GetRaw ¶
func (mv *MetadataValue) GetRaw() (interface{}, bool)
func (*MetadataValue) GetString ¶
func (mv *MetadataValue) GetString() (string, bool)
func (*MetadataValue) GetStringArray ¶ added in v0.3.5
func (mv *MetadataValue) GetStringArray() ([]string, bool)
func (*MetadataValue) MarshalJSON ¶
func (mv *MetadataValue) MarshalJSON() ([]byte, error)
MarshalJSON ensures only the correct type is serialized.
func (*MetadataValue) String ¶
func (mv *MetadataValue) String() string
func (*MetadataValue) UnmarshalJSON ¶
func (mv *MetadataValue) UnmarshalJSON(b []byte) error
UnmarshalJSON properly detects and assigns the correct type.
type MinK ¶ added in v0.3.0
MinK selects k records with the smallest values (ascending order). Use when lower values are better (e.g., distance scores, prices).
func NewMinK ¶ added in v0.3.0
NewMinK creates a MinK aggregation that selects k records with smallest values.
Example:
NewMinK(3, KScore) // Top 3 lowest scores
NewMinK(2, K("priority"), KScore) // With tiebreaker
func (*MinK) MarshalJSON ¶ added in v0.3.0
type MinRank ¶ added in v0.3.0
type MinRank struct {
// contains filtered or unexported fields
}
MinRank represents the minimum of multiple rank expressions. Serializes to JSON as {"$min": [...]}.
func (*MinRank) MarshalJSON ¶ added in v0.3.0
func (*MinRank) UnmarshalJSON ¶ added in v0.3.0
type ModifyConfigOption ¶ added in v0.3.5
type ModifyConfigOption func(*UpdateCollectionConfiguration)
ModifyConfigOption is a functional option for building an UpdateCollectionConfiguration.
func WithHNSWBatchSizeModify ¶ added in v0.3.5
func WithHNSWBatchSizeModify(v uint) ModifyConfigOption
func WithHNSWEfSearchModify ¶ added in v0.3.5
func WithHNSWEfSearchModify(v uint) ModifyConfigOption
func WithHNSWNumThreadsModify ¶ added in v0.3.5
func WithHNSWNumThreadsModify(v uint) ModifyConfigOption
func WithHNSWResizeFactorModify ¶ added in v0.3.5
func WithHNSWResizeFactorModify(v float64) ModifyConfigOption
func WithHNSWSyncThresholdModify ¶ added in v0.3.5
func WithHNSWSyncThresholdModify(v uint) ModifyConfigOption
func WithSpannEfSearchModify ¶ added in v0.3.5
func WithSpannEfSearchModify(v uint) ModifyConfigOption
func WithSpannSearchNprobeModify ¶ added in v0.3.5
func WithSpannSearchNprobeModify(v uint) ModifyConfigOption
type MulRank ¶ added in v0.3.0
type MulRank struct {
// contains filtered or unexported fields
}
MulRank represents multiplication of multiple rank expressions. Serializes to JSON as {"$mul": [...]}.
func (*MulRank) MarshalJSON ¶ added in v0.3.0
func (*MulRank) UnmarshalJSON ¶ added in v0.3.0
type Operand ¶ added in v0.3.0
type Operand interface {
IsOperand()
}
Operand is an interface for values that can participate in rank expressions. Concrete types include IntOperand, FloatOperand, and all Rank implementations.
type OperationType ¶
type OperationType string
type Option ¶
type Option func(*CollectionImpl) error
type Page ¶ added in v0.3.2
type Page struct {
// contains filtered or unexported fields
}
Page provides fluent pagination for Get and Search operations. Use NewPage to create this option.
Page implements both GetOption and SearchRequestOption, following the same pattern as WithIDs. Validation is performed via the Page.Validate method, which is called automatically when the option is applied.
func NewPage ¶ added in v0.3.2
func NewPage(opts ...PageOption) *Page
NewPage creates a new Page with the given options. Default limit is 10 if not specified.
Validation is deferred until the Page is applied to an operation (via Page.Validate), keeping the API ergonomic for inline usage.
Example:
// Inline usage - validation happens at apply time
result, err := col.Search(ctx, NewSearchRequest(
WithKnnRank(KnnQueryText("query")),
NewPage(Limit(20)),
))
// Iteration pattern
page := NewPage(Limit(20))
page = page.Next()
func (*Page) ApplyToGet ¶ added in v0.3.2
func (p *Page) ApplyToGet(op *CollectionGetOp) error
ApplyToGet implements GetOption.
func (*Page) ApplyToSearchRequest ¶ added in v0.3.2
func (p *Page) ApplyToSearchRequest(req *SearchRequest) error
ApplyToSearchRequest implements SearchRequestOption.
func (*Page) Next ¶ added in v0.3.2
Next returns a new Page for the next set of results. If the next offset would overflow, returns a Page at maximum offset.
Example:
page := NewPage(Limit(20)) // page.GetOffset() == 0 page = page.Next() // page.GetOffset() == 20 page = page.Next() // page.GetOffset() == 40
func (*Page) Number ¶ added in v0.3.2
Number returns the current page number (0-indexed).
Example:
page := NewPage(Limit(20), Offset(40)) // page.Number() == 2 (third page, 0-indexed)
func (*Page) Prev ¶ added in v0.3.2
Prev returns a new Page for the previous set of results. The offset is clamped to 0 if it would go negative.
Example:
page := NewPage(Limit(20), Offset(40)) // page.GetOffset() == 40 page = page.Prev() // page.GetOffset() == 20 page = page.Prev() // page.GetOffset() == 0 page = page.Prev() // page.GetOffset() == 0 (clamped)
type PageOption ¶ added in v0.3.2
type PageOption func(*Page)
PageOption configures a Page.
func Limit ¶ added in v0.3.2
func Limit(n int) PageOption
Limit sets the page size (number of results per page). Must be > 0. Validation is deferred until Page.Validate is called.
Example:
page := NewPage(Limit(20))
func Offset ¶ added in v0.3.2
func Offset(n int) PageOption
Offset sets the starting offset (number of results to skip). Must be >= 0. Validation is deferred until Page.Validate is called.
Example:
page := NewPage(Limit(20), Offset(40)) // Page 3 (0-indexed)
type PageOpts
deprecated
added in
v0.3.0
type PageOpts func(page *SearchPage) error
PageOpts configures pagination options for WithPage.
Deprecated: Use NewPage with Limit and Offset instead.
func PageOffset
deprecated
added in
v0.3.2
func SearchWithLimit
deprecated
added in
v0.3.2
func SearchWithOffset
deprecated
added in
v0.3.2
type PersistentClient ¶ added in v0.4.0
type PersistentClient struct {
Client
// contains filtered or unexported fields
}
PersistentClient hosts Chroma in-process using chroma-go-local.
It delegates to either embedded mode (default) or local HTTP server mode, depending on runtime configuration.
func (*PersistentClient) BaseURL ¶ added in v0.4.0
func (client *PersistentClient) BaseURL() string
BaseURL returns the local server URL when running in server mode. Embedded mode returns an empty string.
func (*PersistentClient) Close ¶ added in v0.4.0
func (client *PersistentClient) Close() error
Close shuts down the local runtime and any wrapped client resources.
type PersistentClientOption ¶ added in v0.4.0
type PersistentClientOption func(*localClientConfig) error
PersistentClientOption configures a PersistentClient.
func WithPersistentAllowReset ¶ added in v0.4.0
func WithPersistentAllowReset(allowReset bool) PersistentClientOption
WithPersistentAllowReset enables/disables local reset behavior.
func WithPersistentClientOption ¶ added in v0.4.0
func WithPersistentClientOption(option ClientOption) PersistentClientOption
WithPersistentClientOption adds one standard ClientOption to the wrapped local client state.
func WithPersistentClientOptions ¶ added in v0.4.0
func WithPersistentClientOptions(options ...ClientOption) PersistentClientOption
WithPersistentClientOptions adds multiple standard ClientOption values to the wrapped local client state.
func WithPersistentConfigPath ¶ added in v0.4.0
func WithPersistentConfigPath(path string) PersistentClientOption
WithPersistentConfigPath starts local runtime from a YAML config file path.
This option is mutually exclusive with WithPersistentRawYAML. It selects server runtime mode because YAML config startup is server-based.
func WithPersistentLibraryAutoDownload ¶ added in v0.4.0
func WithPersistentLibraryAutoDownload(enabled bool) PersistentClientOption
WithPersistentLibraryAutoDownload enables/disables automatic library download when no explicit path is provided.
Resolution order: 1. WithPersistentLibraryPath(...) 2. CHROMA_LIB_PATH 3. auto-download (when enabled)
func WithPersistentLibraryCacheDir ¶ added in v0.4.0
func WithPersistentLibraryCacheDir(path string) PersistentClientOption
WithPersistentLibraryCacheDir sets the cache directory used for downloaded local runtime libraries.
func WithPersistentLibraryPath ¶ added in v0.4.0
func WithPersistentLibraryPath(path string) PersistentClientOption
WithPersistentLibraryPath sets the path to the local runtime shared library.
Resolution order in NewPersistentClient: 1. WithPersistentLibraryPath 2. `CHROMA_LIB_PATH` 3. Auto-download from `chroma-go-local` releases (when enabled)
func WithPersistentLibraryVersion ¶ added in v0.4.0
func WithPersistentLibraryVersion(version string) PersistentClientOption
WithPersistentLibraryVersion sets the chroma-go-local release tag used for auto-downloading the runtime library.
Examples: "v0.2.0", "0.2.0"
func WithPersistentListenAddress ¶ added in v0.4.0
func WithPersistentListenAddress(address string) PersistentClientOption
WithPersistentListenAddress sets the local server listen address.
This option selects server runtime mode.
func WithPersistentPath ¶ added in v0.4.0
func WithPersistentPath(path string) PersistentClientOption
WithPersistentPath sets the local persistence directory.
func WithPersistentPort ¶ added in v0.4.0
func WithPersistentPort(port int) PersistentClientOption
WithPersistentPort sets the local server port.
Use `0` to auto-select an available port. If unset, server mode defaults to port `8000`. This option selects server runtime mode.
func WithPersistentRawYAML ¶ added in v0.4.0
func WithPersistentRawYAML(yaml string) PersistentClientOption
WithPersistentRawYAML starts local runtime from an inline YAML config string.
This option is mutually exclusive with WithPersistentConfigPath. It selects server runtime mode because YAML config startup is server-based.
func WithPersistentRuntimeMode ¶ added in v0.4.0
func WithPersistentRuntimeMode(mode PersistentRuntimeMode) PersistentClientOption
WithPersistentRuntimeMode selects how NewPersistentClient runs local Chroma.
type PersistentRuntimeMode ¶ added in v0.4.0
type PersistentRuntimeMode string
PersistentRuntimeMode controls how NewPersistentClient hosts Chroma locally.
const ( // PersistentRuntimeModeEmbedded runs Chroma in-process via the embedded Rust shim. PersistentRuntimeModeEmbedded PersistentRuntimeMode = "embedded" // PersistentRuntimeModeServer runs Chroma in-process but serves the HTTP API locally. PersistentRuntimeModeServer PersistentRuntimeMode = "server" )
type ProjectOp ¶
type ProjectOp struct {
Include []Include `json:"include,omitempty"`
}
ProjectOp specifies which fields to include in results.
type QueryOption ¶ added in v0.3.2
type QueryOption interface {
ApplyToQuery(*CollectionQueryOp) error
}
QueryOption configures a [Collection.Query] operation. Implementations include WithIDs, WithWhere, WithWhereDocument, WithInclude, WithNResults, WithQueryTexts, and WithQueryEmbeddings.
func WithIDsQuery
deprecated
added in
v0.2.1
func WithIDsQuery(ids ...DocumentID) QueryOption
Deprecated: Use WithIDs instead.
func WithIncludeQuery
deprecated
added in
v0.2.1
func WithIncludeQuery(include ...Include) QueryOption
Deprecated: Use WithInclude instead.
func WithWhereDocumentQuery
deprecated
func WithWhereDocumentQuery(whereDocument WhereDocumentFilter) QueryOption
Deprecated: Use WithWhereDocument instead.
func WithWhereQuery
deprecated
func WithWhereQuery(where WhereFilter) QueryOption
Deprecated: Use WithWhere instead.
type QueryOptionFunc ¶ added in v0.3.2
type QueryOptionFunc func(*CollectionQueryOp) error
QueryOptionFunc wraps a function as a QueryOption. Use this to create custom Query options without defining a new type.
func (QueryOptionFunc) ApplyToQuery ¶ added in v0.3.2
func (f QueryOptionFunc) ApplyToQuery(op *CollectionQueryOp) error
ApplyToQuery implements QueryOption.
type QueryResult ¶
type QueryResult interface {
GetIDGroups() []DocumentIDs
GetDocumentsGroups() []Documents
GetMetadatasGroups() []DocumentMetadatas
GetEmbeddingsGroups() []embeddings.Embeddings
GetDistancesGroups() []embeddings.Distances
ToRecordsGroups() []Records
CountGroups() int
}
type QueryResultImpl ¶
type QueryResultImpl struct {
IDLists []DocumentIDs `json:"ids"`
DocumentsLists []Documents `json:"documents,omitempty"`
MetadatasLists []DocumentMetadatas `json:"metadatas,omitempty"`
EmbeddingsLists []embeddings.Embeddings `json:"embeddings,omitempty"`
DistancesLists []embeddings.Distances `json:"distances,omitempty"`
Include []Include `json:"include,omitempty"`
}
func (*QueryResultImpl) At ¶ added in v0.3.0
func (r *QueryResultImpl) At(group, index int) (ResultRow, bool)
At returns the result at the given group and index with bounds checking. Returns false if either index is out of bounds.
func (*QueryResultImpl) CountGroups ¶
func (r *QueryResultImpl) CountGroups() int
func (*QueryResultImpl) GetDistancesGroups ¶
func (r *QueryResultImpl) GetDistancesGroups() []embeddings.Distances
func (*QueryResultImpl) GetDocumentsGroups ¶
func (r *QueryResultImpl) GetDocumentsGroups() []Documents
func (*QueryResultImpl) GetEmbeddingsGroups ¶
func (r *QueryResultImpl) GetEmbeddingsGroups() []embeddings.Embeddings
func (*QueryResultImpl) GetIDGroups ¶
func (r *QueryResultImpl) GetIDGroups() []DocumentIDs
func (*QueryResultImpl) GetMetadatasGroups ¶
func (r *QueryResultImpl) GetMetadatasGroups() []DocumentMetadatas
func (*QueryResultImpl) RowGroups ¶ added in v0.3.0
func (r *QueryResultImpl) RowGroups() [][]ResultRow
RowGroups returns all query groups as [][]ResultRow.
func (*QueryResultImpl) Rows ¶ added in v0.3.0
func (r *QueryResultImpl) Rows() []ResultRow
Rows returns the first query group's results for easy iteration. For multiple query groups, use RowGroups().
func (*QueryResultImpl) String ¶ added in v0.2.1
func (r *QueryResultImpl) String() string
func (*QueryResultImpl) ToRecordsGroups ¶
func (r *QueryResultImpl) ToRecordsGroups() []Records
func (*QueryResultImpl) UnmarshalJSON ¶
func (r *QueryResultImpl) UnmarshalJSON(data []byte) error
type Rank ¶ added in v0.3.0
type Rank interface {
Operand
Multiply(operand Operand) Rank
Sub(operand Operand) Rank
Add(operand Operand) Rank
Div(operand Operand) Rank
Negate() Rank
Abs() Rank
Exp() Rank
Log() Rank
Max(operand Operand) Rank
Min(operand Operand) Rank
MarshalJSON() ([]byte, error)
UnmarshalJSON(b []byte) error
}
Rank is the core interface for building ranking expressions.
Rank expressions are composable through arithmetic operations (Add, Sub, Multiply, Div) and mathematical functions (Abs, Exp, Log, Max, Min). Each operation returns a new Rank, enabling fluent method chaining.
Example - weighted combination of two KNN searches:
rank := NewKnnRank(KnnQueryText("machine learning")).
Multiply(FloatOperand(0.7)).
Add(NewKnnRank(KnnQueryText("deep learning")).Multiply(FloatOperand(0.3)))
Example - log compression with offset:
rank := NewKnnRank(KnnQueryText("query")).Add(FloatOperand(1)).Log()
type RankWithWeight ¶ added in v0.3.0
RankWithWeight pairs a Rank with a weight for use in Reciprocal Rank Fusion (RRF).
Create using the WithWeight method on KnnRank:
knn, _ := NewKnnRank(KnnQueryText("query"), WithKnnReturnRank())
weighted := knn.WithWeight(0.5)
type ReadLevel ¶ added in v0.3.1
type ReadLevel string
ReadLevel controls whether search queries read from the write-ahead log (WAL).
Use WithReadLevel to set this on a search query.
const ( // ReadLevelIndexAndWAL reads from both the compacted index and the WAL (default). // All committed writes will be visible. This is the safest option for // read-after-write consistency. ReadLevelIndexAndWAL ReadLevel = "index_and_wal" // ReadLevelIndexOnly reads only from the compacted index, skipping the WAL. // Faster for large collections, but recent writes that haven't been compacted // may not be visible. Use this for performance-critical searches where // eventual consistency is acceptable. ReadLevelIndexOnly ReadLevel = "index_only" )
type Record ¶
type Record interface {
ID() DocumentID
Document() Document // should work for both text and URI based documents
Embedding() embeddings.Embedding
Metadata() DocumentMetadata
Validate() error
Unwrap() (DocumentID, Document, embeddings.Embedding, DocumentMetadata)
}
type RecordOption ¶
type RecordOption func(record *SimpleRecord) error
func WithRecordEmbedding ¶
func WithRecordEmbedding(embedding embeddings.Embedding) RecordOption
func WithRecordID ¶
func WithRecordID(id string) RecordOption
func WithRecordMetadatas ¶
func WithRecordMetadatas(metadata DocumentMetadata) RecordOption
type ResourceOperation ¶
type ResourceOperation interface {
Resource() Resource
Operation() OperationType
}
type ResultRow ¶ added in v0.3.0
type ResultRow struct {
ID DocumentID
Document string // Empty if not included in results
Metadata DocumentMetadata // nil if not included in results
Embedding []float32 // nil if not included in results
Score float64 // Search: relevance score (higher=better); Query: distance (lower=better); Get: 0
}
ResultRow represents a single result item with all associated data. Use this with Rows() or At() for ergonomic iteration over results.
type RrfOption ¶ added in v0.3.2
RrfOption configures RrfRank parameters.
func WithRffNormalize
deprecated
added in
v0.3.0
func WithRffNormalize() RrfOption
Deprecated: Use WithRrfNormalize instead.
func WithRffRanks
deprecated
added in
v0.3.0
func WithRffRanks(ranks ...RankWithWeight) RrfOption
Deprecated: Use WithRrfRanks instead.
func WithRrfK ¶ added in v0.3.2
WithRrfK sets the smoothing constant for RRF. Default is 60. Higher values reduce the impact of rank differences.
func WithRrfNormalize ¶ added in v0.3.2
func WithRrfNormalize() RrfOption
WithRrfNormalize enables weight normalization so weights sum to 1.0.
func WithRrfRanks ¶ added in v0.3.2
func WithRrfRanks(ranks ...RankWithWeight) RrfOption
WithRrfRanks adds weighted ranking expressions to RRF. Each rank should use WithKnnReturnRank to return rank positions instead of distances.
Example:
rrf, _ := NewRrfRank(
WithRrfRanks(
NewKnnRank(KnnQueryText("query1"), WithKnnReturnRank()).WithWeight(0.5),
NewKnnRank(KnnQueryText("query2"), WithKnnReturnRank()).WithWeight(0.5),
),
)
type RrfRank ¶ added in v0.3.0
type RrfRank struct {
Ranks []RankWithWeight
K int
Normalize bool
}
RrfRank implements Reciprocal Rank Fusion for combining multiple ranking strategies.
RRF uses the formula: -sum(weight_i / (k + rank_i))
This is useful for combining semantic search with keyword search, or multiple embedding types. Each input rank should use WithKnnReturnRank to return positions rather than distances.
Example:
rrf, err := NewRrfRank(
WithRrfRanks(
NewKnnRank(KnnQueryText("AI"), WithKnnReturnRank()).WithWeight(1.0),
NewKnnRank(KnnQueryText("ML"), WithKnnReturnRank()).WithWeight(1.0),
),
WithRrfK(60),
)
func NewRrfRank ¶ added in v0.3.0
func (*RrfRank) MarshalJSON ¶ added in v0.3.0
func (*RrfRank) UnmarshalJSON ¶ added in v0.3.0
type SHA256Generator ¶
type SHA256Generator struct{}
func NewSHA256Generator ¶
func NewSHA256Generator() *SHA256Generator
func (*SHA256Generator) Generate ¶
func (s *SHA256Generator) Generate(opts ...IDGeneratorOption) string
type Schema ¶ added in v0.3.0
type Schema struct {
// contains filtered or unexported fields
}
Schema manages index configurations for a collection
func NewSchema ¶ added in v0.3.0
func NewSchema(opts ...SchemaOption) (*Schema, error)
NewSchema creates a new Schema with the given options.
Example:
schema, err := NewSchema(
WithDefaultVectorIndex(NewVectorIndexConfig(WithSpace(SpaceCosine))),
WithStringIndex("category"),
WithIntIndex("year"),
)
if err != nil {
// handle error
}
For a schema with default L2 vector index, use NewSchemaWithDefaults.
func NewSchemaWithDefaults ¶ added in v0.3.0
NewSchemaWithDefaults creates a Schema with L2 vector index configuration. All other indexes (FTS, string, int, float, bool) are enabled by default in Chroma, so they don't need to be explicitly set.
func (*Schema) Cmek ¶ added in v0.3.0
Cmek returns the customer-managed encryption key configuration, if set
func (*Schema) Defaults ¶ added in v0.3.0
func (s *Schema) Defaults() *ValueTypes
Defaults returns the default value types configuration
func (*Schema) GetAllSparseEmbeddingFunctions ¶ added in v0.3.0
func (s *Schema) GetAllSparseEmbeddingFunctions() map[string]embeddings.SparseEmbeddingFunction
GetAllSparseEmbeddingFunctions returns all sparse embedding functions with their keys Returns a map of key name to embedding function, or nil if schema is nil
func (*Schema) GetEmbeddingFunction ¶ added in v0.3.0
func (s *Schema) GetEmbeddingFunction() embeddings.EmbeddingFunction
GetEmbeddingFunction returns the EmbeddingFunction from the default vector index (#embedding key) Returns nil if no vector index is configured or if the EmbeddingFunction couldn't be reconstructed
func (*Schema) GetKey ¶ added in v0.3.0
func (s *Schema) GetKey(key string) (*ValueTypes, bool)
GetKey returns the value types for a specific key
func (*Schema) GetSparseEmbeddingFunction ¶ added in v0.3.0
func (s *Schema) GetSparseEmbeddingFunction(key string) embeddings.SparseEmbeddingFunction
GetSparseEmbeddingFunction returns the SparseEmbeddingFunction from a specific key Returns nil if no sparse vector index is configured at that key or if the EmbeddingFunction couldn't be reconstructed
func (*Schema) IsFtsEnabled ¶ added in v0.4.0
IsFtsEnabled reports whether FTS is enabled, preferring DocumentKey overrides and falling back to defaults for backward compatibility with legacy schemas.
func (*Schema) MarshalJSON ¶ added in v0.3.0
MarshalJSON serializes the Schema to JSON
func (*Schema) SetEmbeddingFunction ¶ added in v0.3.0
func (s *Schema) SetEmbeddingFunction(ef embeddings.EmbeddingFunction)
SetEmbeddingFunction sets the EmbeddingFunction on the default vector index (#embedding key) Creates the necessary structure if it doesn't exist
func (*Schema) SetSparseEmbeddingFunction ¶ added in v0.3.0
func (s *Schema) SetSparseEmbeddingFunction(key string, ef embeddings.SparseEmbeddingFunction)
SetSparseEmbeddingFunction sets the SparseEmbeddingFunction on a specific key Creates the necessary structure if it doesn't exist
func (*Schema) UnmarshalJSON ¶ added in v0.3.0
UnmarshalJSON deserializes the Schema from JSON
type SchemaOption ¶ added in v0.3.0
SchemaOption configures a Schema
func DisableBoolIndex ¶ added in v0.3.0
func DisableBoolIndex(key string) SchemaOption
func DisableDefaultBoolIndex ¶ added in v0.3.0
func DisableDefaultBoolIndex() SchemaOption
func DisableDefaultFloatIndex ¶ added in v0.3.0
func DisableDefaultFloatIndex() SchemaOption
func DisableDefaultFtsIndex
deprecated
added in
v0.3.0
func DisableDefaultFtsIndex() SchemaOption
DisableDefaultFtsIndex disables FTS on defaults and DocumentKey. This keeps backward compatibility for callers inspecting schema defaults. Note: this also adds/updates a DocumentKey override and may change serialized schema keys.
Deprecated: Use DisableDocumentFtsIndex or DisableFtsIndex with DocumentKey instead.
func DisableDefaultIntIndex ¶ added in v0.3.0
func DisableDefaultIntIndex() SchemaOption
func DisableDefaultStringIndex ¶ added in v0.3.0
func DisableDefaultStringIndex() SchemaOption
func DisableDocumentFtsIndex ¶ added in v0.4.0
func DisableDocumentFtsIndex() SchemaOption
DisableDocumentFtsIndex disables full-text search for the reserved DocumentKey. Chroma applies FTS on DocumentKey, not on schema defaults.
func DisableFloatIndex ¶ added in v0.3.0
func DisableFloatIndex(key string) SchemaOption
func DisableFtsIndex ¶ added in v0.3.0
func DisableFtsIndex(key string) SchemaOption
func DisableIntIndex ¶ added in v0.3.0
func DisableIntIndex(key string) SchemaOption
func DisableStringIndex ¶ added in v0.3.0
func DisableStringIndex(key string) SchemaOption
func WithBoolIndex ¶ added in v0.3.0
func WithBoolIndex(key string) SchemaOption
func WithCmek ¶ added in v0.3.0
func WithCmek(cmek *Cmek) SchemaOption
WithCmek sets a customer-managed encryption key for the schema. Returns an error if the CMEK is nil or has an invalid resource format.
func WithDefaultFtsIndex ¶ added in v0.3.0
func WithDefaultFtsIndex(cfg *FtsIndexConfig) SchemaOption
func WithDefaultSparseVectorIndex ¶ added in v0.3.0
func WithDefaultSparseVectorIndex(cfg *SparseVectorIndexConfig) SchemaOption
func WithDefaultVectorIndex ¶ added in v0.3.0
func WithDefaultVectorIndex(cfg *VectorIndexConfig) SchemaOption
func WithFloatIndex ¶ added in v0.3.0
func WithFloatIndex(key string) SchemaOption
func WithFtsIndex ¶ added in v0.3.0
func WithFtsIndex(key string) SchemaOption
func WithIntIndex ¶ added in v0.3.0
func WithIntIndex(key string) SchemaOption
func WithSparseVectorIndex ¶ added in v0.3.0
func WithSparseVectorIndex(key string, cfg *SparseVectorIndexConfig) SchemaOption
func WithStringIndex ¶ added in v0.3.0
func WithStringIndex(key string) SchemaOption
func WithVectorIndex ¶ added in v0.3.0
func WithVectorIndex(key string, cfg *VectorIndexConfig) SchemaOption
type SearchCollectionOption ¶ added in v0.3.0
type SearchCollectionOption func(update *SearchQuery) error
SearchCollectionOption configures a SearchQuery for [Collection.Search].
Use NewSearchRequest to create search requests, and WithReadLevel to set the read consistency level.
func NewSearchRequest ¶ added in v0.3.0
func NewSearchRequest(opts ...SearchRequestOption) SearchCollectionOption
NewSearchRequest creates a search request and adds it to the query.
Example:
result, err := collection.Search(ctx,
NewSearchRequest(
WithKnnRank(KnnQueryText("machine learning"), WithKnnLimit(50)),
WithFilter(EqString(K("status"), "published")),
WithPage(PageLimit(10)),
WithSelect(KDocument, KScore),
),
)
func WithReadLevel ¶ added in v0.3.1
func WithReadLevel(level ReadLevel) SearchCollectionOption
WithReadLevel sets the read consistency level for the search query.
Use ReadLevelIndexOnly for faster searches when eventual consistency is acceptable. Recent writes that haven't been compacted may not be visible.
Default is ReadLevelIndexAndWAL which includes all committed writes.
Example ¶
result, err := collection.Search(ctx,
NewSearchRequest(WithKnnRank(KnnQueryText("query"))),
WithReadLevel(ReadLevelIndexOnly), // Faster but eventual consistency
)
type SearchFilter ¶ added in v0.3.0
type SearchFilter struct {
// IDs limits results to specific document IDs.
// Converted to #id $in clause during serialization.
IDs []DocumentID `json:"-"`
// Where specifies metadata filter criteria.
Where WhereClause `json:"-"`
}
SearchFilter specifies which documents to include in search results.
Filters can combine ID-based and metadata-based criteria. When both IDs and Where clauses are provided, they are combined with AND logic.
Use WithIDs and WithFilter (or WithSearchWhere) to build filters:
NewSearchRequest(
WithKnnRank(KnnQueryText("query")),
WithIDs("doc1", "doc2", "doc3"),
WithFilter(EqString(K("status"), "published")),
)
func (*SearchFilter) AppendIDs ¶ added in v0.3.2
func (f *SearchFilter) AppendIDs(ids ...DocumentID)
AppendIDs adds document IDs to the filter.
func (*SearchFilter) MarshalJSON ¶ added in v0.3.0
func (f *SearchFilter) MarshalJSON() ([]byte, error)
func (*SearchFilter) SetSearchWhere ¶ added in v0.3.2
func (f *SearchFilter) SetSearchWhere(where WhereClause)
SetSearchWhere sets the metadata filter clause.
type SearchOption ¶ added in v0.3.0
type SearchOption = SearchRequestOption
SearchOption is an alias for SearchRequestOption for backward compatibility.
type SearchPage
deprecated
added in
v0.3.0
type SearchQuery ¶ added in v0.3.0
type SearchQuery struct {
// Searches contains the individual search requests.
Searches []SearchRequest `json:"searches"`
// ReadLevel controls read consistency (default: ReadLevelIndexAndWAL).
ReadLevel ReadLevel `json:"read_level,omitempty"`
}
SearchQuery holds one or more search requests to execute as a batch.
Use NewSearchRequest to add requests and WithReadLevel to set consistency.
type SearchRequest ¶ added in v0.3.0
type SearchRequest struct {
// Filter specifies which documents to include (by ID or metadata).
Filter *SearchFilter `json:"filter,omitempty"`
// Limit specifies pagination (limit and offset).
Limit *SearchPage `json:"limit,omitempty"`
// Rank specifies the ranking expression (e.g., KNN similarity).
Rank Rank `json:"rank,omitempty"`
// Select specifies which fields to include in results.
Select *SearchSelect `json:"select,omitempty"`
// GroupBy groups results by metadata field values.
GroupBy *GroupBy `json:"group_by,omitempty"`
}
SearchRequest represents a single search operation with filter, ranking, pagination, and projection.
Create using NewSearchRequest with options:
NewSearchRequest(
WithKnnRank(KnnQueryText("machine learning")),
WithFilter(EqString(K("status"), "published")),
WithPage(PageLimit(10)),
WithSelect(KDocument, KScore),
)
func (*SearchRequest) MarshalJSON ¶ added in v0.3.0
func (r *SearchRequest) MarshalJSON() ([]byte, error)
type SearchRequestOption ¶ added in v0.3.2
type SearchRequestOption interface {
ApplyToSearchRequest(*SearchRequest) error
}
SearchRequestOption configures a SearchRequest for [Collection.Search]. Implementations include WithIDs, WithSearchWhere, WithFilter, WithPage, WithSelect, WithSelectAll, WithRank, WithKnnRank, and WithGroupBy.
func WithFilter ¶ added in v0.3.0
func WithFilter(where WhereClause) SearchRequestOption
WithFilter adds a metadata filter to the search.
Use K to mark metadata field names in filter expressions. Combine multiple conditions with And and Or.
Available Filter Functions ¶
Equality: EqString, EqInt, EqFloat, EqBool, [NeString], [NeInt], etc. Comparison: GtInt, GteInt, LtInt, LteInt, GtFloat, etc. Set operations: InString, InInt, NinString, NinInt, etc. Logical: And, Or ID filtering: IDIn
Example ¶
NewSearchRequest(
WithKnnRank(KnnQueryText("query")),
WithFilter(And(
EqString(K("status"), "published"),
GtInt(K("views"), 100),
)),
)
func WithFilterIDs
deprecated
added in
v0.3.0
func WithFilterIDs(ids ...DocumentID) SearchRequestOption
Deprecated: Use WithIDs instead.
type SearchRequestOptionFunc ¶ added in v0.3.2
type SearchRequestOptionFunc func(*SearchRequest) error
SearchRequestOptionFunc wraps a function as a SearchRequestOption. Use this to create custom Search options without defining a new type.
func (SearchRequestOptionFunc) ApplyToSearchRequest ¶ added in v0.3.2
func (f SearchRequestOptionFunc) ApplyToSearchRequest(req *SearchRequest) error
ApplyToSearchRequest implements SearchRequestOption.
type SearchResult ¶ added in v0.3.0
type SearchResult interface{}
SearchResult represents the result of a search operation. The concrete type is *SearchResultImpl.
type SearchResultImpl ¶ added in v0.3.0
type SearchResultImpl struct {
// IDs contains document IDs for each query result set.
// IDs[queryIndex][resultIndex] is the ID of the result.
IDs [][]DocumentID `json:"ids,omitempty"`
// Documents contains document text for each query result set.
// Only populated if [WithSelect] included [KDocument].
Documents [][]string `json:"documents,omitempty"`
// Metadatas contains metadata for each query result set.
// Only populated if [WithSelect] included [KMetadata] or specific fields.
Metadatas [][]DocumentMetadata `json:"metadatas,omitempty"`
// Embeddings contains vector embeddings for each query result set.
// Only populated if [WithSelect] included [KEmbedding].
Embeddings [][][]float32 `json:"embeddings,omitempty"`
// Scores contains ranking scores for each query result set.
// Only populated if [WithSelect] included [KScore].
Scores [][]float64 `json:"scores,omitempty"`
}
SearchResultImpl holds the results of a search operation.
Results are organized as nested arrays where the outer array corresponds to each search request in the batch, and the inner arrays contain the matching documents.
Accessing Results ¶
Use SearchResultImpl.Rows for single-query results:
result, _ := collection.Search(ctx, NewSearchRequest(...))
for _, row := range result.(*SearchResultImpl).Rows() {
fmt.Printf("ID: %s, Score: %f\n", row.ID, row.Score)
}
Use SearchResultImpl.RowGroups for batch queries:
result, _ := collection.Search(ctx, req1, req2, req3)
for i, group := range result.(*SearchResultImpl).RowGroups() {
fmt.Printf("Query %d results:\n", i)
for _, row := range group {
fmt.Printf(" ID: %s, Score: %f\n", row.ID, row.Score)
}
}
Use SearchResultImpl.At for random access:
row, ok := result.(*SearchResultImpl).At(0, 5) // First query, 6th result
func (*SearchResultImpl) At ¶ added in v0.3.0
func (r *SearchResultImpl) At(group, index int) (ResultRow, bool)
At returns the result at the given group and index with bounds checking. Returns false if either index is out of bounds.
func (*SearchResultImpl) RowGroups ¶ added in v0.3.0
func (r *SearchResultImpl) RowGroups() [][]ResultRow
RowGroups returns all search groups as [][]ResultRow.
func (*SearchResultImpl) Rows ¶ added in v0.3.0
func (r *SearchResultImpl) Rows() []ResultRow
Rows returns the first search group's results for easy iteration. For multiple search requests, use RowGroups().
func (*SearchResultImpl) UnmarshalJSON ¶ added in v0.3.0
func (r *SearchResultImpl) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshalling for SearchResultImpl. This is necessary because DocumentMetadata is an interface type that cannot be directly unmarshalled by the standard JSON decoder.
type SearchSelect ¶ added in v0.3.0
type SearchSelect struct {
// Keys contains the field keys to include in results.
// Use [KDocument], [KEmbedding], [KScore], [KMetadata], [KID] for standard fields,
// or [K]("field_name") for custom metadata fields.
Keys []Key `json:"keys,omitempty"`
}
SearchSelect specifies which fields to include in search results.
Use WithSelect or WithSelectAll to configure field selection:
WithSelect(KDocument, KScore, K("title"), K("author"))
type SimpleRecord ¶
type SimpleRecord struct {
// contains filtered or unexported fields
}
func NewSimpleRecord ¶
func NewSimpleRecord(opts ...RecordOption) (*SimpleRecord, error)
func (*SimpleRecord) Document ¶
func (r *SimpleRecord) Document() Document
func (*SimpleRecord) Embedding ¶
func (r *SimpleRecord) Embedding() embeddings.Embedding
func (*SimpleRecord) ID ¶
func (r *SimpleRecord) ID() DocumentID
func (*SimpleRecord) Metadata ¶
func (r *SimpleRecord) Metadata() DocumentMetadata
func (*SimpleRecord) URI ¶
func (r *SimpleRecord) URI() string
func (*SimpleRecord) Unwrap ¶
func (r *SimpleRecord) Unwrap() (DocumentID, Document, embeddings.Embedding, DocumentMetadata)
func (*SimpleRecord) Validate ¶
func (r *SimpleRecord) Validate() error
type SortOp ¶
type SortOp struct {
Sort string `json:"sort,omitempty"`
}
SortOp specifies result ordering (not yet supported).
type Space ¶ added in v0.3.0
type Space string
Space represents the distance metric for vector similarity search
type SpannIndexConfig ¶ added in v0.3.0
type SpannIndexConfig struct {
SearchNprobe uint `json:"search_nprobe,omitempty" default:"64" validate:"omitempty,min=1,max=128"`
SearchRngFactor float64 `json:"search_rng_factor,omitempty" default:"1.0"`
SearchRngEpsilon float64 `json:"search_rng_epsilon,omitempty" default:"10.0" validate:"omitempty,min=5.0,max=10.0"`
NReplicaCount uint `json:"nreplica_count,omitempty" default:"8" validate:"omitempty,min=1,max=8"`
WriteRngFactor float64 `json:"write_rng_factor,omitempty" default:"1.0"`
WriteRngEpsilon float64 `json:"write_rng_epsilon,omitempty" default:"5.0" validate:"omitempty,min=5.0,max=10.0"`
SplitThreshold uint `json:"split_threshold,omitempty" default:"50" validate:"omitempty,min=50,max=200"`
NumSamplesKmeans uint `json:"num_samples_kmeans,omitempty" default:"1000" validate:"omitempty,min=1,max=1000"`
InitialLambda float64 `json:"initial_lambda,omitempty" default:"100.0"`
ReassignNeighborCount uint `json:"reassign_neighbor_count,omitempty" default:"64" validate:"omitempty,min=1,max=64"`
MergeThreshold uint `json:"merge_threshold,omitempty" default:"25" validate:"omitempty,min=25,max=100"`
NumCentersToMergeTo uint `json:"num_centers_to_merge_to,omitempty" default:"8" validate:"omitempty,min=1,max=8"`
WriteNprobe uint `json:"write_nprobe,omitempty" default:"32" validate:"omitempty,min=1,max=64"`
EfConstruction uint `json:"ef_construction,omitempty" default:"200" validate:"omitempty,min=1,max=200"`
EfSearch uint `json:"ef_search,omitempty" default:"200" validate:"omitempty,min=1,max=200"`
MaxNeighbors uint `json:"max_neighbors,omitempty" default:"64" validate:"omitempty,min=1,max=64"`
Quantize SpannQuantization `json:"quantize,omitempty" validate:"omitempty,oneof=none four_bit_rabit_q_with_u_search"`
}
SpannIndexConfig represents SPANN algorithm configuration for Chroma Cloud
func NewSpannConfig ¶ added in v0.3.0
func NewSpannConfig(opts ...SpannOption) *SpannIndexConfig
NewSpannConfig creates a new SpannIndexConfig with the given options
func NewSpannConfigWithDefaults ¶ added in v0.3.0
func NewSpannConfigWithDefaults(opts ...SpannOption) (*SpannIndexConfig, error)
NewSpannConfigWithDefaults creates a new SpannIndexConfig with defaults applied and validation
type SpannOption ¶ added in v0.3.0
type SpannOption func(*SpannIndexConfig)
SpannOption configures a SpannIndexConfig
func WithSpannEfConstruction ¶ added in v0.3.0
func WithSpannEfConstruction(ef uint) SpannOption
func WithSpannEfSearch ¶ added in v0.3.0
func WithSpannEfSearch(ef uint) SpannOption
func WithSpannInitialLambda ¶ added in v0.3.0
func WithSpannInitialLambda(l float64) SpannOption
func WithSpannMaxNeighbors ¶ added in v0.3.0
func WithSpannMaxNeighbors(m uint) SpannOption
func WithSpannMergeThreshold ¶ added in v0.3.0
func WithSpannMergeThreshold(t uint) SpannOption
func WithSpannNReplicaCount ¶ added in v0.3.0
func WithSpannNReplicaCount(n uint) SpannOption
func WithSpannNumCentersToMergeTo ¶ added in v0.3.0
func WithSpannNumCentersToMergeTo(n uint) SpannOption
func WithSpannNumSamplesKmeans ¶ added in v0.3.0
func WithSpannNumSamplesKmeans(n uint) SpannOption
func WithSpannQuantize ¶ added in v0.4.0
func WithSpannQuantize(q SpannQuantization) SpannOption
func WithSpannReassignNeighborCount ¶ added in v0.3.0
func WithSpannReassignNeighborCount(n uint) SpannOption
func WithSpannSearchNprobe ¶ added in v0.3.0
func WithSpannSearchNprobe(n uint) SpannOption
func WithSpannSearchRngEpsilon ¶ added in v0.3.0
func WithSpannSearchRngEpsilon(e float64) SpannOption
func WithSpannSearchRngFactor ¶ added in v0.3.0
func WithSpannSearchRngFactor(f float64) SpannOption
func WithSpannSplitThreshold ¶ added in v0.3.0
func WithSpannSplitThreshold(t uint) SpannOption
func WithSpannWriteNprobe ¶ added in v0.3.0
func WithSpannWriteNprobe(n uint) SpannOption
func WithSpannWriteRngEpsilon ¶ added in v0.3.0
func WithSpannWriteRngEpsilon(e float64) SpannOption
func WithSpannWriteRngFactor ¶ added in v0.3.0
func WithSpannWriteRngFactor(f float64) SpannOption
type SpannQuantization ¶ added in v0.4.0
type SpannQuantization string
SpannQuantization represents supported quantization implementations for SPANN.
const ( SpannQuantizationNone SpannQuantization = "none" // RaBitQ naming follows upstream Chroma and the wire value. SpannQuantizationFourBitRabitQWithUSearch SpannQuantization = "four_bit_rabit_q_with_u_search" // Deprecated: Use [SpannQuantizationFourBitRabitQWithUSearch] instead. SpannQuantizationFourBitRabbitQWithUSearch = SpannQuantizationFourBitRabitQWithUSearch )
type SparseVectorIndexConfig ¶ added in v0.3.0
type SparseVectorIndexConfig struct {
EmbeddingFunction embeddings.SparseEmbeddingFunction `json:"-"`
SourceKey string `json:"source_key,omitempty"`
BM25 bool `json:"bm25,omitempty"`
}
SparseVectorIndexConfig represents configuration for sparse vector indexing
func NewSparseVectorIndexConfig ¶ added in v0.3.0
func NewSparseVectorIndexConfig(opts ...SparseVectorIndexOption) *SparseVectorIndexConfig
NewSparseVectorIndexConfig creates a new SparseVectorIndexConfig with the given options
func (*SparseVectorIndexConfig) MarshalJSON ¶ added in v0.3.0
func (s *SparseVectorIndexConfig) MarshalJSON() ([]byte, error)
MarshalJSON serializes SparseVectorIndexConfig to JSON, including EmbeddingFunction as EmbeddingFunctionInfo
func (*SparseVectorIndexConfig) UnmarshalJSON ¶ added in v0.3.0
func (s *SparseVectorIndexConfig) UnmarshalJSON(data []byte) error
UnmarshalJSON deserializes SparseVectorIndexConfig from JSON, optionally reconstructing EmbeddingFunction
type SparseVectorIndexOption ¶ added in v0.3.0
type SparseVectorIndexOption func(*SparseVectorIndexConfig)
SparseVectorIndexOption configures a SparseVectorIndexConfig
func WithBM25 ¶ added in v0.3.0
func WithBM25(enabled bool) SparseVectorIndexOption
func WithSparseEmbeddingFunction ¶ added in v0.3.0
func WithSparseEmbeddingFunction(ef embeddings.SparseEmbeddingFunction) SparseVectorIndexOption
func WithSparseSourceKey ¶ added in v0.3.0
func WithSparseSourceKey(key string) SparseVectorIndexOption
type SparseVectorIndexType ¶ added in v0.3.0
type SparseVectorIndexType struct {
Enabled bool `json:"enabled"`
Config *SparseVectorIndexConfig `json:"config,omitempty"`
}
SparseVectorIndexType wraps SparseVectorIndexConfig with enabled state
type SparseVectorValueType ¶ added in v0.3.0
type SparseVectorValueType struct {
SparseVectorIndex *SparseVectorIndexType `json:"sparse_vector_index,omitempty"`
}
SparseVectorValueType defines indexes for sparse vectors
type StringInvertedIndexConfig ¶ added in v0.3.0
type StringInvertedIndexConfig struct{}
Inverted index configs for metadata fields
type StringInvertedIndexType ¶ added in v0.3.0
type StringInvertedIndexType struct {
Enabled bool `json:"enabled"`
Config *StringInvertedIndexConfig `json:"config,omitempty"`
}
StringInvertedIndexType wraps StringInvertedIndexConfig with enabled state
type StringValueType ¶ added in v0.3.0
type StringValueType struct {
FtsIndex *FtsIndexType `json:"fts_index,omitempty"`
StringInvertedIndex *StringInvertedIndexType `json:"string_inverted_index,omitempty"`
}
StringValueType defines indexes applicable to string fields
type SubRank ¶ added in v0.3.0
type SubRank struct {
// contains filtered or unexported fields
}
SubRank represents subtraction of two rank expressions. Serializes to JSON as {"$sub": {"left": ..., "right": ...}}.
func (*SubRank) MarshalJSON ¶ added in v0.3.0
func (*SubRank) UnmarshalJSON ¶ added in v0.3.0
type SumRank ¶ added in v0.3.0
type SumRank struct {
// contains filtered or unexported fields
}
SumRank represents the addition of multiple rank expressions. Serializes to JSON as {"$sum": [...]}.
func (*SumRank) MarshalJSON ¶ added in v0.3.0
func (*SumRank) UnmarshalJSON ¶ added in v0.3.0
type Tenant ¶
type Tenant interface {
Name() string
String() string
Database(dbName string) Database
Validate() error
}
func NewDefaultTenant ¶
func NewDefaultTenant() Tenant
func NewTenantFromJSON ¶
type TenantBase ¶
type TenantBase struct {
TenantName string `json:"name"`
}
func (*TenantBase) Database ¶
func (t *TenantBase) Database(dbName string) Database
Database returns a new Database object that can be used for creating collections
func (*TenantBase) Name ¶
func (t *TenantBase) Name() string
func (*TenantBase) String ¶
func (t *TenantBase) String() string
func (*TenantBase) Validate ¶
func (t *TenantBase) Validate() error
type TextDocument ¶
type TextDocument struct {
Content string
}
func NewTextDocument ¶
func NewTextDocument(content string) *TextDocument
func (*TextDocument) ContentRaw ¶
func (d *TextDocument) ContentRaw() []byte
func (*TextDocument) ContentString ¶
func (d *TextDocument) ContentString() string
func (*TextDocument) MarshalJSON ¶
func (d *TextDocument) MarshalJSON() ([]byte, error)
func (*TextDocument) String ¶ added in v0.2.1
func (d *TextDocument) String() string
func (*TextDocument) UnmarshalJSON ¶
func (d *TextDocument) UnmarshalJSON(data []byte) error
type TextDocuments ¶
type TextDocuments []TextDocument
func NewTextDocumentsFromInterface ¶
func NewTextDocumentsFromInterface(docs []interface{}) (TextDocuments, error)
type TokenAuthCredentialsProvider ¶
type TokenAuthCredentialsProvider struct {
Token string
Header TokenTransportHeader
}
func NewTokenAuthCredentialsProvider ¶
func NewTokenAuthCredentialsProvider(token string, header TokenTransportHeader) *TokenAuthCredentialsProvider
func (*TokenAuthCredentialsProvider) Authenticate ¶
func (t *TokenAuthCredentialsProvider) Authenticate() (map[string]string, error)
func (*TokenAuthCredentialsProvider) String ¶ added in v0.2.4
func (t *TokenAuthCredentialsProvider) String() string
type TokenTransportHeader ¶
type TokenTransportHeader string
const ( AuthorizationTokenHeader TokenTransportHeader = "Authorization" XChromaTokenHeader TokenTransportHeader = "X-Chroma-Token" )
type ULIDGenerator ¶
type ULIDGenerator struct{}
func NewULIDGenerator ¶
func NewULIDGenerator() *ULIDGenerator
func (*ULIDGenerator) Generate ¶
func (u *ULIDGenerator) Generate(opts ...IDGeneratorOption) string
type UUIDGenerator ¶
type UUIDGenerator struct{}
func NewUUIDGenerator ¶
func NewUUIDGenerator() *UUIDGenerator
func (*UUIDGenerator) Generate ¶
func (u *UUIDGenerator) Generate(opts ...IDGeneratorOption) string
type UnknownRank ¶ added in v0.3.0
type UnknownRank struct {
ValRank
}
UnknownRank is a sentinel type returned by operandToRank when an unknown operand type is encountered. It errors on MarshalJSON to surface programming errors instead of silently producing incorrect results.
func (*UnknownRank) MarshalJSON ¶ added in v0.3.0
func (u *UnknownRank) MarshalJSON() ([]byte, error)
type UpdateCollectionConfiguration ¶ added in v0.3.5
type UpdateCollectionConfiguration struct {
Hnsw *UpdateHNSWConfiguration `json:"hnsw,omitempty"`
Spann *UpdateSpannConfiguration `json:"spann,omitempty"`
}
UpdateCollectionConfiguration holds configuration updates for an existing collection. Only non-nil fields will be sent to the server.
func NewUpdateCollectionConfiguration ¶ added in v0.3.5
func NewUpdateCollectionConfiguration(opts ...ModifyConfigOption) *UpdateCollectionConfiguration
NewUpdateCollectionConfiguration creates an UpdateCollectionConfiguration from functional options.
func (*UpdateCollectionConfiguration) GetRaw ¶ added in v0.3.5
func (u *UpdateCollectionConfiguration) GetRaw(key string) (any, bool)
func (*UpdateCollectionConfiguration) Validate ¶ added in v0.3.5
func (u *UpdateCollectionConfiguration) Validate() error
type UpdateHNSWConfiguration ¶ added in v0.3.5
type UpdateHNSWConfiguration struct {
EfSearch *uint `json:"ef_search,omitempty"`
NumThreads *uint `json:"num_threads,omitempty"`
BatchSize *uint `json:"batch_size,omitempty"`
SyncThreshold *uint `json:"sync_threshold,omitempty"`
ResizeFactor *float64 `json:"resize_factor,omitempty"`
}
UpdateHNSWConfiguration contains mutable HNSW parameters that can be changed after collection creation.
type UpdateOption ¶ added in v0.3.2
type UpdateOption interface {
ApplyToUpdate(*CollectionUpdateOp) error
}
UpdateOption configures a [Collection.Update] operation. Implementations include WithIDs, WithTexts, WithEmbeddings, and WithMetadatas.
func WithEmbeddingsUpdate
deprecated
added in
v0.2.3
func WithEmbeddingsUpdate(embs ...embeddings.Embedding) UpdateOption
Deprecated: Use WithEmbeddings instead.
func WithIDsUpdate
deprecated
added in
v0.2.3
func WithIDsUpdate(ids ...DocumentID) UpdateOption
Deprecated: Use WithIDs instead.
func WithMetadatasUpdate
deprecated
added in
v0.2.3
func WithMetadatasUpdate(metadatas ...DocumentMetadata) UpdateOption
Deprecated: Use WithMetadatas instead.
func WithTextsUpdate
deprecated
added in
v0.2.3
func WithTextsUpdate(documents ...string) UpdateOption
Deprecated: Use WithTexts instead.
type UpdateOptionFunc ¶ added in v0.3.2
type UpdateOptionFunc func(*CollectionUpdateOp) error
UpdateOptionFunc wraps a function as an UpdateOption. Use this to create custom Update options without defining a new type.
func (UpdateOptionFunc) ApplyToUpdate ¶ added in v0.3.2
func (f UpdateOptionFunc) ApplyToUpdate(op *CollectionUpdateOp) error
ApplyToUpdate implements UpdateOption.
type UpdateSpannConfiguration ¶ added in v0.3.5
type UpdateSpannConfiguration struct {
SearchNprobe *uint `json:"search_nprobe,omitempty"`
EfSearch *uint `json:"ef_search,omitempty"`
}
UpdateSpannConfiguration contains mutable SPANN parameters that can be changed after collection creation.
type ValRank ¶ added in v0.3.0
type ValRank struct {
// contains filtered or unexported fields
}
ValRank represents a constant numeric value in rank expressions. Serializes to JSON as {"$val": <value>}.
func Val ¶ added in v0.3.0
Val creates a constant value rank expression.
Example:
// Add a constant offset to KNN scores
rank := NewKnnRank(KnnQueryText("query")).Add(Val(1.0))
// Create a weighted scalar
rank := Val(0.5).Multiply(NewKnnRank(KnnQueryText("query")))
func (*ValRank) MarshalJSON ¶ added in v0.3.0
func (*ValRank) UnmarshalJSON ¶ added in v0.3.0
type ValueTypes ¶ added in v0.3.0
type ValueTypes struct {
String *StringValueType `json:"string,omitempty"`
FloatList *FloatListValueType `json:"float_list,omitempty"`
SparseVector *SparseVectorValueType `json:"sparse_vector,omitempty"`
Int *IntValueType `json:"int,omitempty"`
Float *FloatValueType `json:"float,omitempty"`
Bool *BoolValueType `json:"bool,omitempty"`
}
ValueTypes contains all value type configurations
type VectorIndexConfig ¶ added in v0.3.0
type VectorIndexConfig struct {
Space Space `json:"space,omitempty"`
EmbeddingFunction embeddings.EmbeddingFunction `json:"-"`
SourceKey string `json:"source_key,omitempty"`
Hnsw *HnswIndexConfig `json:"hnsw,omitempty"`
Spann *SpannIndexConfig `json:"spann,omitempty"`
}
VectorIndexConfig represents configuration for dense vector indexing
func NewVectorIndexConfig ¶ added in v0.3.0
func NewVectorIndexConfig(opts ...VectorIndexOption) *VectorIndexConfig
NewVectorIndexConfig creates a new VectorIndexConfig with the given options
func (*VectorIndexConfig) MarshalJSON ¶ added in v0.3.0
func (v *VectorIndexConfig) MarshalJSON() ([]byte, error)
MarshalJSON serializes VectorIndexConfig to JSON, including EmbeddingFunction as EmbeddingFunctionInfo
func (*VectorIndexConfig) UnmarshalJSON ¶ added in v0.3.0
func (v *VectorIndexConfig) UnmarshalJSON(data []byte) error
UnmarshalJSON deserializes VectorIndexConfig from JSON, optionally reconstructing EmbeddingFunction
type VectorIndexOption ¶ added in v0.3.0
type VectorIndexOption func(*VectorIndexConfig)
VectorIndexOption configures a VectorIndexConfig
func WithHnsw ¶ added in v0.3.0
func WithHnsw(cfg *HnswIndexConfig) VectorIndexOption
func WithSourceKey ¶ added in v0.3.0
func WithSourceKey(key string) VectorIndexOption
func WithSpace ¶ added in v0.3.0
func WithSpace(space Space) VectorIndexOption
func WithSpann ¶ added in v0.3.0
func WithSpann(cfg *SpannIndexConfig) VectorIndexOption
func WithVectorEmbeddingFunction ¶ added in v0.3.0
func WithVectorEmbeddingFunction(ef embeddings.EmbeddingFunction) VectorIndexOption
type VectorIndexType ¶ added in v0.3.0
type VectorIndexType struct {
Enabled bool `json:"enabled"`
Config *VectorIndexConfig `json:"config,omitempty"`
}
VectorIndexType wraps VectorIndexConfig with enabled state
type WhereClause ¶
type WhereClause interface {
Operator() WhereFilterOperator
Key() string
Operand() interface{}
String() string
Validate() error
MarshalJSON() ([]byte, error)
UnmarshalJSON(b []byte) error
}
func And ¶
func And(clauses ...WhereClause) WhereClause
func DocumentContains ¶ added in v0.3.0
func DocumentContains(text string) WhereClause
DocumentContains creates a where clause that filters documents containing the specified text. Use this with Search API to filter by document content.
Example:
WithFilter(DocumentContains("machine learning"))
func DocumentNotContains ¶ added in v0.3.0
func DocumentNotContains(text string) WhereClause
DocumentNotContains creates a where clause that filters out documents containing the specified text. Use this with Search API to exclude documents with certain content.
Example:
WithFilter(DocumentNotContains("deprecated"))
func EqBool ¶
func EqBool(field Key, value bool) WhereClause
func EqFloat ¶
func EqFloat(field Key, value float32) WhereClause
func EqInt ¶
func EqInt(field Key, value int) WhereClause
func EqString ¶
func EqString(field Key, value string) WhereClause
func GtFloat ¶
func GtFloat(field Key, value float32) WhereClause
func GtInt ¶
func GtInt(field Key, value int) WhereClause
func GteFloat ¶
func GteFloat(field Key, value float32) WhereClause
func GteInt ¶
func GteInt(field Key, value int) WhereClause
func IDIn ¶ added in v0.3.0
func IDIn(ids ...DocumentID) WhereClause
IDIn creates a where clause that matches documents with any of the specified IDs. Use this in combination with other where clauses via And() or Or().
Example:
WithFilter(And(EqString(K("status"), "published"), IDIn("doc1", "doc2", "doc3")))
func IDNotIn ¶ added in v0.3.0
func IDNotIn(ids ...DocumentID) WhereClause
IDNotIn creates a where clause that excludes documents with any of the specified IDs. Use this to filter out already-seen or unwanted documents from search results.
Example:
WithFilter(IDNotIn("seen1", "seen2", "seen3"))
func InBool ¶
func InBool(field Key, values ...bool) WhereClause
func InFloat ¶
func InFloat(field Key, values ...float32) WhereClause
func InInt ¶
func InInt(field Key, values ...int) WhereClause
func InString ¶
func InString(field Key, values ...string) WhereClause
func LtFloat ¶
func LtFloat(field Key, value float32) WhereClause
func LtInt ¶
func LtInt(field Key, value int) WhereClause
func LteFloat ¶
func LteFloat(field Key, value float32) WhereClause
func LteInt ¶
func LteInt(field Key, value int) WhereClause
func MetadataContainsBool ¶ added in v0.3.5
func MetadataContainsBool(field Key, value bool) WhereClause
func MetadataContainsFloat ¶ added in v0.3.5
func MetadataContainsFloat(field Key, value float32) WhereClause
func MetadataContainsInt ¶ added in v0.3.5
func MetadataContainsInt(field Key, value int) WhereClause
func MetadataContainsString ¶ added in v0.3.5
func MetadataContainsString(field Key, value string) WhereClause
func MetadataNotContainsBool ¶ added in v0.3.5
func MetadataNotContainsBool(field Key, value bool) WhereClause
func MetadataNotContainsFloat ¶ added in v0.3.5
func MetadataNotContainsFloat(field Key, value float32) WhereClause
func MetadataNotContainsInt ¶ added in v0.3.5
func MetadataNotContainsInt(field Key, value int) WhereClause
func MetadataNotContainsString ¶ added in v0.3.5
func MetadataNotContainsString(field Key, value string) WhereClause
func NinBool ¶
func NinBool(field Key, values ...bool) WhereClause
func NinFloat ¶
func NinFloat(field Key, values ...float32) WhereClause
func NinInt ¶
func NinInt(field Key, values ...int) WhereClause
func NinString ¶
func NinString(field Key, values ...string) WhereClause
func NotEqBool ¶
func NotEqBool(field Key, value bool) WhereClause
func NotEqFloat ¶
func NotEqFloat(field Key, value float32) WhereClause
func NotEqInt ¶
func NotEqInt(field Key, value int) WhereClause
func NotEqString ¶
func NotEqString(field Key, value string) WhereClause
func Or ¶
func Or(clauses ...WhereClause) WhereClause
type WhereClauseBase ¶
type WhereClauseBase struct {
// contains filtered or unexported fields
}
func (*WhereClauseBase) Key ¶
func (w *WhereClauseBase) Key() string
func (*WhereClauseBase) Operator ¶
func (w *WhereClauseBase) Operator() WhereFilterOperator
func (*WhereClauseBase) String ¶
func (w *WhereClauseBase) String() string
type WhereClauseBool ¶
type WhereClauseBool struct {
WhereClauseBase
// contains filtered or unexported fields
}
func (*WhereClauseBool) MarshalJSON ¶
func (w *WhereClauseBool) MarshalJSON() ([]byte, error)
func (*WhereClauseBool) Operand ¶
func (w *WhereClauseBool) Operand() interface{}
func (*WhereClauseBool) UnmarshalJSON ¶
func (w *WhereClauseBool) UnmarshalJSON(b []byte) error
func (*WhereClauseBool) Validate ¶
func (w *WhereClauseBool) Validate() error
type WhereClauseBools ¶
type WhereClauseBools struct {
WhereClauseBase
// contains filtered or unexported fields
}
func (*WhereClauseBools) MarshalJSON ¶
func (w *WhereClauseBools) MarshalJSON() ([]byte, error)
func (*WhereClauseBools) Operand ¶
func (w *WhereClauseBools) Operand() interface{}
func (*WhereClauseBools) UnmarshalJSON ¶
func (w *WhereClauseBools) UnmarshalJSON(b []byte) error
func (*WhereClauseBools) Validate ¶
func (w *WhereClauseBools) Validate() error
type WhereClauseFloat ¶
type WhereClauseFloat struct {
WhereClauseBase
// contains filtered or unexported fields
}
func (*WhereClauseFloat) MarshalJSON ¶
func (w *WhereClauseFloat) MarshalJSON() ([]byte, error)
func (*WhereClauseFloat) Operand ¶
func (w *WhereClauseFloat) Operand() interface{}
func (*WhereClauseFloat) UnmarshalJSON ¶
func (w *WhereClauseFloat) UnmarshalJSON(b []byte) error
func (*WhereClauseFloat) Validate ¶
func (w *WhereClauseFloat) Validate() error
type WhereClauseFloats ¶
type WhereClauseFloats struct {
WhereClauseBase
// contains filtered or unexported fields
}
func (*WhereClauseFloats) MarshalJSON ¶
func (w *WhereClauseFloats) MarshalJSON() ([]byte, error)
func (*WhereClauseFloats) Operand ¶
func (w *WhereClauseFloats) Operand() interface{}
func (*WhereClauseFloats) UnmarshalJSON ¶
func (w *WhereClauseFloats) UnmarshalJSON(b []byte) error
func (*WhereClauseFloats) Validate ¶
func (w *WhereClauseFloats) Validate() error
type WhereClauseInt ¶
type WhereClauseInt struct {
WhereClauseBase
// contains filtered or unexported fields
}
func (*WhereClauseInt) MarshalJSON ¶
func (w *WhereClauseInt) MarshalJSON() ([]byte, error)
func (*WhereClauseInt) Operand ¶
func (w *WhereClauseInt) Operand() interface{}
func (*WhereClauseInt) UnmarshalJSON ¶
func (w *WhereClauseInt) UnmarshalJSON(b []byte) error
func (*WhereClauseInt) Validate ¶
func (w *WhereClauseInt) Validate() error
type WhereClauseInts ¶
type WhereClauseInts struct {
WhereClauseBase
// contains filtered or unexported fields
}
func (*WhereClauseInts) MarshalJSON ¶
func (w *WhereClauseInts) MarshalJSON() ([]byte, error)
func (*WhereClauseInts) Operand ¶
func (w *WhereClauseInts) Operand() interface{}
func (*WhereClauseInts) UnmarshalJSON ¶
func (w *WhereClauseInts) UnmarshalJSON(b []byte) error
func (*WhereClauseInts) Validate ¶
func (w *WhereClauseInts) Validate() error
type WhereClauseString ¶
type WhereClauseString struct {
WhereClauseBase
// contains filtered or unexported fields
}
func (*WhereClauseString) MarshalJSON ¶
func (w *WhereClauseString) MarshalJSON() ([]byte, error)
func (*WhereClauseString) Operand ¶
func (w *WhereClauseString) Operand() interface{}
func (*WhereClauseString) UnmarshalJSON ¶
func (w *WhereClauseString) UnmarshalJSON(b []byte) error
func (*WhereClauseString) Validate ¶
func (w *WhereClauseString) Validate() error
type WhereClauseStrings ¶
type WhereClauseStrings struct {
WhereClauseBase
// contains filtered or unexported fields
}
func (*WhereClauseStrings) MarshalJSON ¶
func (w *WhereClauseStrings) MarshalJSON() ([]byte, error)
func (*WhereClauseStrings) Operand ¶
func (w *WhereClauseStrings) Operand() interface{}
func (*WhereClauseStrings) UnmarshalJSON ¶
func (w *WhereClauseStrings) UnmarshalJSON(b []byte) error
func (*WhereClauseStrings) Validate ¶
func (w *WhereClauseStrings) Validate() error
type WhereClauseWhereClauses ¶
type WhereClauseWhereClauses struct {
WhereClauseBase
// contains filtered or unexported fields
}
func (*WhereClauseWhereClauses) MarshalJSON ¶
func (w *WhereClauseWhereClauses) MarshalJSON() ([]byte, error)
func (*WhereClauseWhereClauses) Operand ¶
func (w *WhereClauseWhereClauses) Operand() interface{}
func (*WhereClauseWhereClauses) UnmarshalJSON ¶
func (w *WhereClauseWhereClauses) UnmarshalJSON(b []byte) error
func (*WhereClauseWhereClauses) Validate ¶
func (w *WhereClauseWhereClauses) Validate() error
type WhereDocumentClauseAnd ¶
type WhereDocumentClauseAnd struct {
WhereDocumentFilterBase
// contains filtered or unexported fields
}
func (*WhereDocumentClauseAnd) MarshalJSON ¶
func (w *WhereDocumentClauseAnd) MarshalJSON() ([]byte, error)
func (*WhereDocumentClauseAnd) String ¶
func (w *WhereDocumentClauseAnd) String() string
func (*WhereDocumentClauseAnd) UnmarshalJSON ¶
func (w *WhereDocumentClauseAnd) UnmarshalJSON(b []byte) error
func (*WhereDocumentClauseAnd) Validate ¶
func (w *WhereDocumentClauseAnd) Validate() error
type WhereDocumentClauseContainsOrNotContains ¶
type WhereDocumentClauseContainsOrNotContains struct {
WhereDocumentFilterBase
// contains filtered or unexported fields
}
func (*WhereDocumentClauseContainsOrNotContains) MarshalJSON ¶
func (w *WhereDocumentClauseContainsOrNotContains) MarshalJSON() ([]byte, error)
func (*WhereDocumentClauseContainsOrNotContains) String ¶
func (w *WhereDocumentClauseContainsOrNotContains) String() string
func (*WhereDocumentClauseContainsOrNotContains) UnmarshalJSON ¶
func (w *WhereDocumentClauseContainsOrNotContains) UnmarshalJSON(b []byte) error
func (*WhereDocumentClauseContainsOrNotContains) Validate ¶
func (w *WhereDocumentClauseContainsOrNotContains) Validate() error
type WhereDocumentClauseOr ¶
type WhereDocumentClauseOr struct {
WhereDocumentFilterBase
// contains filtered or unexported fields
}
func (*WhereDocumentClauseOr) MarshalJSON ¶
func (w *WhereDocumentClauseOr) MarshalJSON() ([]byte, error)
func (*WhereDocumentClauseOr) String ¶
func (w *WhereDocumentClauseOr) String() string
func (*WhereDocumentClauseOr) UnmarshalJSON ¶
func (w *WhereDocumentClauseOr) UnmarshalJSON(b []byte) error
func (*WhereDocumentClauseOr) Validate ¶
func (w *WhereDocumentClauseOr) Validate() error
type WhereDocumentClauseRegexNotRegex ¶ added in v0.2.4
type WhereDocumentClauseRegexNotRegex struct {
WhereDocumentFilterBase
// contains filtered or unexported fields
}
func (*WhereDocumentClauseRegexNotRegex) MarshalJSON ¶ added in v0.2.4
func (w *WhereDocumentClauseRegexNotRegex) MarshalJSON() ([]byte, error)
func (*WhereDocumentClauseRegexNotRegex) String ¶ added in v0.2.4
func (w *WhereDocumentClauseRegexNotRegex) String() string
func (*WhereDocumentClauseRegexNotRegex) UnmarshalJSON ¶ added in v0.2.4
func (w *WhereDocumentClauseRegexNotRegex) UnmarshalJSON(b []byte) error
func (*WhereDocumentClauseRegexNotRegex) Validate ¶ added in v0.2.4
func (w *WhereDocumentClauseRegexNotRegex) Validate() error
type WhereDocumentFilter ¶
type WhereDocumentFilter interface {
Operator() WhereDocumentFilterOperator
Operand() interface{}
Validate() error
String() string
MarshalJSON() ([]byte, error)
UnmarshalJSON(b []byte) error
}
func AndDocument ¶
func AndDocument(clauses ...WhereDocumentFilter) WhereDocumentFilter
func Contains ¶
func Contains(content string) WhereDocumentFilter
func NotContains ¶
func NotContains(content string) WhereDocumentFilter
func NotRegex ¶ added in v0.2.4
func NotRegex(content string) WhereDocumentFilter
func OrDocument ¶
func OrDocument(clauses ...WhereDocumentFilter) WhereDocumentFilter
func Regex ¶ added in v0.2.4
func Regex(content string) WhereDocumentFilter
type WhereDocumentFilterBase ¶
type WhereDocumentFilterBase struct {
// contains filtered or unexported fields
}
func (*WhereDocumentFilterBase) MarshalJSON ¶
func (w *WhereDocumentFilterBase) MarshalJSON() ([]byte, error)
func (*WhereDocumentFilterBase) Operand ¶
func (w *WhereDocumentFilterBase) Operand() interface{}
func (*WhereDocumentFilterBase) Operator ¶
func (w *WhereDocumentFilterBase) Operator() WhereDocumentFilterOperator
func (*WhereDocumentFilterBase) String ¶
func (w *WhereDocumentFilterBase) String() string
func (*WhereDocumentFilterBase) UnmarshalJSON ¶
func (w *WhereDocumentFilterBase) UnmarshalJSON(b []byte) error
func (*WhereDocumentFilterBase) Validate ¶
func (w *WhereDocumentFilterBase) Validate() error
type WhereDocumentFilterOperator ¶
type WhereDocumentFilterOperator string
const ( ContainsOperator WhereDocumentFilterOperator = "$contains" NotContainsOperator WhereDocumentFilterOperator = "$not_contains" RegexOperator WhereDocumentFilterOperator = "$regex" NotRegexOperator WhereDocumentFilterOperator = "$not_regex" OrDocumentOperator WhereDocumentFilterOperator = "$or" AndDocumentOperator WhereDocumentFilterOperator = "$and" )
type WhereFilter ¶
type WhereFilterOperator ¶
type WhereFilterOperator string
const ( EqualOperator WhereFilterOperator = "$eq" NotEqualOperator WhereFilterOperator = "$ne" GreaterThanOperator WhereFilterOperator = "$gt" GreaterThanOrEqualOperator WhereFilterOperator = "$gte" LessThanOperator WhereFilterOperator = "$lt" LessThanOrEqualOperator WhereFilterOperator = "$lte" InOperator WhereFilterOperator = "$in" NotInOperator WhereFilterOperator = "$nin" AndOperator WhereFilterOperator = "$and" OrOperator WhereFilterOperator = "$or" ContainsWhereOperator WhereFilterOperator = "$contains" NotContainsWhereOperator WhereFilterOperator = "$not_contains" )
Source Files
¶
- aggregate.go
- auth.go
- base.go
- client.go
- client_cloud.go
- client_http.go
- client_local.go
- client_local_embedded.go
- client_local_library_download.go
- collection.go
- collection_http.go
- configuration.go
- constants.go
- document.go
- groupby.go
- ids.go
- metadata.go
- options.go
- page.go
- rank.go
- record.go
- reranking.go
- results.go
- schema.go
- search.go
- utils.go
- where.go
- where_document.go