Index configuration
These fields ofclient.createIndex() configure the index. There is no indexConfig argument and no IndexIVFFlat / IndexIVFPQ / IndexIVFSQ types.
MetadataFieldPolicy
Key management
Pass exactly one of the two to
createIndex(); passing both throws CyborgDBValidationError.
VectorItem
The object shapeupsert() accepts:
Query result
query() resolves to a QueryResponse whose results is a flat array for one query vector, and an array of arrays for a batch:
QueryResultItem has id, and optionally distance (vector queries; lower is closer), score (hybrid queries, instead of distance; higher is more relevant), and metadata. QueryResponse.results is typed QueryResultItem[] | QueryResultItem[][]; narrow it with a cast to the shape your call returns.
MetadataResult
The item typequeryMetadata() resolves to:
BM25Config
Returned by thebm25() getter:
Field selection
include picks the fields returned besides id:
get() defaults to ['vector', 'contents', 'metadata']; query() defaults to [], which returns only id.
Metadata filtering
filters on query() and queryMetadata() uses MongoDB-style operators. Nested fields use dot-paths such as 'loc.city'.
Operators
$gt, $gte, $lt, and $lte require a number; any other value throws CyborgDBValidationError. $not can’t be nested inside a field ({ price: { $not: ... } } is rejected); wrap the whole condition instead. $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.
Examples
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 storeDate objects: the SDK sends them as ISO strings, which only support equality filters.
Date with:
Distance metrics
Response types
Since v0.18,
UpsertResponse and DeleteResponse no longer declare upsertedCount / deletedCount; those fields were never set. message reports how many IDs were sent, not how many existed: deleting an ID that doesn’t exist still counts it.
TypeScript types
JSON types
Filter types
FilterOperator places $not inside a field, which the service rejects. A top-level { $not: { ... } } filter works on the service but doesn’t match these types; cast it with as FilterExpression.
Request models
The package also exports the generated request and response modelsCreateIndexRequest, UpsertRequest, BatchQueryRequest, TrainRequest, GetRequest, DeleteRequest, IndexOperationRequest, GetResponseModel, ErrorResponseModel, and HTTPValidationError. The SDK methods build these for you; you only need them to call the REST API directly.
Utility functions
VERSION is the SDK version string, e.g. '0.18.0'.