Classes
Client
The main TopK client for interacting with the TopK service. This client provides access to collections and allows you to perform various operations like creating collections, querying data, and managing documents. Constructors ConstructorParameter | Type |
---|---|
config | ClientConfig |
Client
Methods
collection()
Parameter | Type |
---|---|
name | string |
CollectionClient
collections()
CollectionsClient
CollectionClient
Internal
Client for interacting with a specific collection.
This client provides methods to perform operations on a specific collection,
including querying, upserting, and deleting documents.
Methods
count()
Parameter | Type |
---|---|
options? | QueryOptions |
Promise
<number
>
delete()
Parameter | Type |
---|---|
ids | string [] |
Promise
<string
>
get()
Parameter | Type |
---|---|
ids | string [] |
fields? | string [] |
options? | QueryOptions |
Promise
<Record
<string
, Record
<string
, any
>>>
query()
Parameter | Type |
---|---|
query | Query |
options? | QueryOptions |
Promise
<Record
<string
, any
>[]>
upsert()
Parameter | Type |
---|---|
docs | Record <string , any >[] |
Promise
<string
>
CollectionsClient
Internal
Client for managing collections.
This client provides methods to create, list, get, and delete collections.
Methods
create()
Parameter | Type |
---|---|
name | string |
schema | Record <string , FieldSpec > |
Promise
<Collection
>
delete()
This operation is irreversible and will permanently delete all data in the collection.
Parameter | Type |
---|---|
name | string |
Promise
<void
>
get()
Parameter | Type |
---|---|
name | string |
Promise
<Collection
>
list()
Promise
<Collection
[]>
Interfaces
BackoffConfig
Configuration for exponential backoff between retry attempts. This struct controls how the delay between retry attempts increases over time. All fields are optional and will use sensible defaults if not provided. PropertiesClientConfig
Configuration for the TopK client. This struct contains all the necessary configuration options to connect to the TopK API. Theapi_key
and region
are required, while other options have sensible defaults.
Properties
Property | Type | Description |
---|---|---|
apiKey | string | Your TopK API key for authentication |
host? | string | Custom host URL (optional, defaults to the standard TopK endpoint) |
https? | boolean | Whether to use HTTPS (optional, defaults to true) |
region | string | The region where your data is stored (e.g., “us-east-1”, “eu-west-1”) |
retryConfig? | RetryConfig | Retry configuration for failed requests (optional) |
Collection
Represents a collection in the TopK service. A collection is a container for documents with a defined schema. This struct contains metadata about the collection including its name, organization, project, schema, and region. PropertiesProperty | Type | Description |
---|---|---|
name | string | Name of the collection |
orgId | string | Organization ID that owns the collection |
projectId | string | Project ID that contains the collection |
region | string | Region where the collection is stored |
schema | Record <string , CollectionFieldSpec > | Schema definition for the collection fields |
CollectionFieldSpec
Represents a field specification within a collection schema. This struct defines the properties of a field in a collection, including its data type, whether it’s required, and any index configuration. PropertiesQueryOptions
Options for query operations. These options control the behavior of query operations, including consistency guarantees and sequence number constraints. PropertiesProperty | Type | Description |
---|---|---|
consistency? | ConsistencyLevel | Consistency level for the query |
lsn? | string | Last sequence number to query at (for consistency) |
RerankOptions
Options for rerank stages. This struct contains configuration options for reranking results, including the model, query, and fields to use. PropertiesRetryConfig
Configuration for retry behavior when requests fail. This struct allows you to customize how the client handles retries for failed requests. All fields are optional and will use sensible defaults if not provided. PropertiesProperty | Type | Description |
---|---|---|
backoff? | BackoffConfig | Backoff configuration for spacing out retry attempts |
maxRetries? | number | Maximum number of retries to attempt before giving up |
timeout? | number | Total timeout for the entire retry chain in milliseconds |
Namespaces
Type Aliases
ConsistencyLevel
Indexed
: Query returns results as soon as they are indexed (faster, eventual consistency)Strong
: Query waits for all replicas to be consistent (slower, strong consistency)