JSON Type Definitions
CyborgDB provides strongly-typed JSON types for improved type safety when working with metadata and other JSON-serializable data.JsonPrimitive
JsonValue
JsonObject
JsonArray
VectorMetadata
Example Usage
CreateIndexRequest
TheCreateIndexRequest interface defines the parameters for creating a new encrypted index.
Properties
Example Usage
UpsertRequest
Interface for adding or updating vectors in an encrypted index.Properties
Example Usage
QueryRequest
Interface for performing similarity search in the encrypted index.Properties
Example Usage
BatchQueryRequest
Interface for performing batch similarity searches with multiple vectors.Properties
Example Usage
TrainRequest
Interface for training an index to optimize query performance.Properties
Example Usage
DeleteRequest
Interface for deleting vectors from the encrypted index.Properties
Example Usage
GetRequest
Interface for retrieving specific vectors from the index.Properties
Example Usage
VectorItem
Class representing a vectorized item for storage in the encrypted index.Properties
Example Usage
Index Configuration Types
IndexIVF
Standard IVF (Inverted File) index configuration, ideal for balanced performance:Properties
Example Usage
IndexIVFFlat
IVFFlat index configuration, suitable for highest accuracy requirements:Properties
Example Usage
IndexIVFPQ
IVFPQ (Product Quantization) index configuration, optimized for memory efficiency:Properties
Example Usage
Response Types
UpsertResponse
Response interface for upsert operations.Properties
Example Usage
DeleteResponse
Response interface for delete operations.Properties
Example Usage
TrainResponse
Response interface for training operations.Properties
Example Usage
HealthResponse
Response interface for health check operations.Properties
Example Usage
TrainingStatus
Response interface for training status queries.Properties
Example Usage
GetResponseModel
Response class for vector retrieval operations.Properties
GetResultItem
Enhanced type-safe result item for get operations. This type extendsGetResultItemModel with proper typing for metadata and contents fields.
Properties
Example Usage
QueryResponse
Response class for similarity search operations.Properties
Example Usage
QueryResultItem
Class representing a single result from similarity search.Properties
Error Types
ErrorResponseModel
Standard error response class for API errors.Properties
HTTPValidationError
Class for validation errors with detailed field information.Properties
Metadata Filtering
Thefilters parameter in query operations supports a subset of MongoDB query operators for flexible metadata filtering:
Supported Operators
$eq: Equality ({ "category": "research" })$ne: Not equal ({ "status": { "$ne": "draft" } })$gt: Greater than ({ "score": { "$gt": 0.8 } })$gte: Greater than or equal ({ "year": { "$gte": 2020 } })$lt: Less than ({ "price": { "$lt": 100 } })$lte: Less than or equal ({ "rating": { "$lte": 4.5 } })$in: In array ({ "tag": { "$in": ["ai", "ml"] } })$nin: Not in array ({ "category": { "$nin": ["spam", "deleted"] } })$and: Logical AND ({ "$and": [{"a": 1}, {"b": 2}] })$or: Logical OR ({ "$or": [{"x": 1}, {"y": 2}] })
Filter Examples
Field Selection
Many operations support field selection through theinclude parameter:
Available Fields
vector: The vector data itselfcontents: Text or binary content associated with the vectormetadata: Structured metadata objectdistance: Similarity distance (query operations only)
Example Usage
Filter Types
FilterExpression
FilterValue
FilterOperator
Example Usage
Utility Functions
The SDK provides type guard and utility functions for safer type checking and error handling.isJsonValue
Parameters
Returns
boolean: Returns true if the value is a valid JSON value, false otherwise.
Example Usage
isError
Parameters
Returns
boolean: Returns true if the value is an Error instance, false otherwise.
Example Usage
getErrorMessage
Parameters
Returns
string: A string message extracted from the error. Returns the error’s message property if it’s an Error, converts to string otherwise.