Skip to main content

Index configuration

These fields of CreateIndexParams configure the index. There is no IndexConfig field and no IndexIVFFlat / IndexIVFPQ / IndexIVFSQ helpers.

MetadataFieldPolicy

Key management

Set exactly one of the two in CreateIndexParams; setting both returns a *ValidationError.

VectorItem

The element type of VectorItems, the JSON form of Upsert:
Set VectorItem.Contents with item.SetContentsString(s), as shown in Upsert. The contents type is exported as cyborgdb.Contents.

Query result

Query returns a *QueryResponse. Its Results field is a union with exactly one side set: QueryResultItem has Id string and Metadata map[string]interface{}, plus GetDistance() / HasDistance() (vector queries; lower is closer) and GetScore() / HasScore() (hybrid queries, instead of distance; higher is more relevant).

QueryMetadataResponse and MetadataResult

QueryMetadata returns:

BM25Config

Returned by the BM25 getter:

Field selection

Include picks the fields returned besides the ID: Get with a nil include returns vector, contents, and metadata; Query with a nil Include returns only the ID.

Metadata filtering

Filters on Query and QueryMetadata is a map[string]interface{} of MongoDB-style operators. Nested fields use dot-paths such as "loc.city".

Operators

The examples are shown as JSON; in Go, each object is a map[string]interface{} and each array a []interface{}. $gt, $gte, $lt, and $lte require a number; any other value returns a *ValidationError. $not can’t be nested inside a field. $regex and $contains resolve from the index only on fields created with Pattern true: Query falls back to a slower post-filter otherwise, and QueryMetadata rejects the filter.

Example

Dates

CyborgDB has no date type. Store dates in metadata as integer milliseconds since the Unix epoch (UTC), so range operators work on them. Don’t store time.Time values: the SDK sends them as RFC 3339 strings, which only support equality filters.
Values come back as float64 after JSON decoding. Convert one back to a time.Time with:

Distance metrics

Other types

Constants

Pointer fields can be set with the helpers cyborgdb.Bool, cyborgdb.Int32, cyborgdb.String, and cyborgdb.Float64, e.g. Dimension: cyborgdb.Int32(384). Error types and sentinel errors are listed in Errors.