> ## Documentation Index
> Fetch the complete documentation index at: https://docs.topk.io/llms.txt
> Use this file to discover all available pages before exploring further.

# topk-js

## Classes

### AskStream

Iterator for ask responses.

This type implements JavaScript's async iterable protocol.
It can be used with `for await...of` loops.

**See**

[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration\_protocols#the\_async\_iterator\_and\_async\_iterable\_protocols](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)

**Constructors**

**Constructor**

```ts theme={null}
new AskStream(): AskStream;
```

**Returns**

[`AskStream`](/sdk/topk-js/index#askstream)

**Methods**

##### \[asyncIterator]\()

```ts theme={null}
asyncIterator: AsyncGenerator<
  | Answer
| Progress, void, undefined>;
```

**Returns**

`AsyncGenerator`\<
\| [`Answer`](/sdk/topk-js/index#answer)
\| [`Progress`](/sdk/topk-js/index#progress), `void`, `undefined`>

***

### Client

Client for interacting with the TopK API. For available regions see [https://docs.topk.io/regions](https://docs.topk.io/regions)

**Constructors**

**Constructor**

```ts theme={null}
new Client(config: ClientConfig): Client;
```

Creates a new TopK client with the provided configuration.

**Parameters**

| Parameter | Type                                              |
| --------- | ------------------------------------------------- |
| `config`  | [`ClientConfig`](/sdk/topk-js/index#clientconfig) |

**Returns**

[`Client`](/sdk/topk-js/index#client)

**Methods**

##### ask()

```ts theme={null}
ask(
   query: string, 
   datasets: (
  | string
  | {
  dataset: string;
  filter?: LogicalExpression;
})[], 
   filter?: LogicalExpression, 
   mode?: Mode, 
   selectFields?: string[], 
   includeContent?: boolean): AskStream;
```

Ask a question and get streaming responses as an async iterator.

**Parameters**

| Parameter         | Type                                                                                                                             |
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `query`           | `string`                                                                                                                         |
| `datasets`        | ( \| `string` \| \{ `dataset`: `string`; `filter?`: [`LogicalExpression`](/sdk/topk-js/Namespace.query#logicalexpression); })\[] |
| `filter?`         | [`LogicalExpression`](/sdk/topk-js/Namespace.query#logicalexpression)                                                            |
| `mode?`           | [`Mode`](/sdk/topk-js/index#mode)                                                                                                |
| `selectFields?`   | `string`\[]                                                                                                                      |
| `includeContent?` | `boolean`                                                                                                                        |

**Returns**

[`AskStream`](/sdk/topk-js/index#askstream)

##### collection()

```ts theme={null}
collection(name: string): CollectionClient;
```

Returns a client for interacting with a specific collection.

**Parameters**

| Parameter | Type     |
| --------- | -------- |
| `name`    | `string` |

**Returns**

[`CollectionClient`](/sdk/topk-js/index#collectionclient)

##### collections()

```ts theme={null}
collections(): CollectionsClient;
```

Returns a client for managing collections.

This method provides access to collection management operations like creating,
listing, and deleting collections.

**Returns**

[`CollectionsClient`](/sdk/topk-js/index#collectionsclient)

##### dataset()

```ts theme={null}
dataset(name: string): DatasetClient;
```

Get a client for managing data operations on a specific dataset such as upserting files, managing metadata, and deleting files.

**Parameters**

| Parameter | Type     |
| --------- | -------- |
| `name`    | `string` |

**Returns**

[`DatasetClient`](/sdk/topk-js/index#datasetclient)

##### datasets()

```ts theme={null}
datasets(): DatasetsClient;
```

Get a client for managing datasets.

**Returns**

[`DatasetsClient`](/sdk/topk-js/index#datasetsclient)

##### search()

```ts theme={null}
search(
   query: string, 
   datasets: (
  | string
  | {
  dataset: string;
  filter?: LogicalExpression;
})[], 
   topK: number, 
   filter?: LogicalExpression, 
   selectFields?: string[]): SearchStream;
```

Search for documents and get streaming responses as an async iterator.

**Parameters**

| Parameter       | Type                                                                                                                             |
| --------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `query`         | `string`                                                                                                                         |
| `datasets`      | ( \| `string` \| \{ `dataset`: `string`; `filter?`: [`LogicalExpression`](/sdk/topk-js/Namespace.query#logicalexpression); })\[] |
| `topK`          | `number`                                                                                                                         |
| `filter?`       | [`LogicalExpression`](/sdk/topk-js/Namespace.query#logicalexpression)                                                            |
| `selectFields?` | `string`\[]                                                                                                                      |

**Returns**

[`SearchStream`](/sdk/topk-js/index#searchstream)

***

### 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()

```ts theme={null}
count(options?: QueryOptions): Promise<number>;
```

Counts the number of documents in the collection.

**Parameters**

| Parameter  | Type                                              |
| ---------- | ------------------------------------------------- |
| `options?` | [`QueryOptions`](/sdk/topk-js/index#queryoptions) |

**Returns**

`Promise`\<`number`>

##### delete()

```ts theme={null}
delete(expr: 
  | string[]
| LogicalExpression): Promise<string>;
```

Deletes documents from the collection by their IDs or using a filter expression.

Example:
Delete documents by their IDs:

```javascript theme={null}
await client.collection("books").delete(["id_1", "id_2"])
```

Delete documents by a filter expression:

```javascript theme={null}
import { field } from "topk-js/query";

await client.collection("books").delete(field("published_year").gt(1997))
```

**Parameters**

| Parameter | Type                                                                                    |
| --------- | --------------------------------------------------------------------------------------- |
| `expr`    | \| `string`\[] \| [`LogicalExpression`](/sdk/topk-js/Namespace.query#logicalexpression) |

**Returns**

`Promise`\<`string`>

##### get()

```ts theme={null}
get(
   ids: string[], 
   fields?: string[], 
options?: QueryOptions): Promise<Record<string, Record<string, any>>>;
```

Retrieves documents by their IDs.

**Parameters**

| Parameter  | Type                                              |
| ---------- | ------------------------------------------------- |
| `ids`      | `string`\[]                                       |
| `fields?`  | `string`\[]                                       |
| `options?` | [`QueryOptions`](/sdk/topk-js/index#queryoptions) |

**Returns**

`Promise`\<`Record`\<`string`, `Record`\<`string`, `any`>>>

##### query()

```ts theme={null}
query(query: Query, options?: QueryOptions): Promise<Record<string, any>[]>;
```

Executes a query against the collection.

**Parameters**

| Parameter  | Type                                              |
| ---------- | ------------------------------------------------- |
| `query`    | [`Query`](/sdk/topk-js/Namespace.query#query)     |
| `options?` | [`QueryOptions`](/sdk/topk-js/index#queryoptions) |

**Returns**

`Promise`\<`Record`\<`string`, `any`>\[]>

##### update()

```ts theme={null}
update(docs: Record<string, any>[], failOnMissing?: boolean): Promise<string>;
```

Updates documents in the collection.

Existing documents will be merged with the provided fields.
Missing documents will be ignored.

**Parameters**

| Parameter        | Type                          |
| ---------------- | ----------------------------- |
| `docs`           | `Record`\<`string`, `any`>\[] |
| `failOnMissing?` | `boolean`                     |

**Returns**

`Promise`\<`string`>

The `LSN` at which the update was applied.
If no updates were applied, this will be empty.

##### upsert()

```ts theme={null}
upsert(docs: Record<string, any>[]): Promise<string>;
```

Inserts or updates documents in the collection.

**Parameters**

| Parameter | Type                          |
| --------- | ----------------------------- |
| `docs`    | `Record`\<`string`, `any`>\[] |

**Returns**

`Promise`\<`string`>

***

### CollectionsClient

**`Internal`**

Client for managing collections.

This client provides methods to create, list, get, and delete collections.

**Methods**

##### create()

```ts theme={null}
create(name: string, schema: Record<string, FieldSpec>): Promise<Collection>;
```

Creates a new collection with the specified schema.

**Parameters**

| Parameter | Type                                                                        |
| --------- | --------------------------------------------------------------------------- |
| `name`    | `string`                                                                    |
| `schema`  | `Record`\<`string`, [`FieldSpec`](/sdk/topk-js/Namespace.schema#fieldspec)> |

**Returns**

`Promise`\<[`Collection`](/sdk/topk-js/index#collection-1)>

##### delete()

```ts theme={null}
delete(name: string): Promise<void>;
```

Deletes a collection and all its data.

<Warning>
  This operation is irreversible and will permanently delete all data in the collection.
</Warning>

**Parameters**

| Parameter | Type     |
| --------- | -------- |
| `name`    | `string` |

**Returns**

`Promise`\<`void`>

##### get()

```ts theme={null}
get(name: string): Promise<Collection>;
```

Retrieves information about a specific collection.

**Parameters**

| Parameter | Type     |
| --------- | -------- |
| `name`    | `string` |

**Returns**

`Promise`\<[`Collection`](/sdk/topk-js/index#collection-1)>

##### list()

```ts theme={null}
list(): Promise<Collection[]>;
```

Lists all collections in the current project.

**Returns**

`Promise`\<[`Collection`](/sdk/topk-js/index#collection-1)\[]>

***

### DatasetClient

**`Internal`**

Client for dataset operations.

**Methods**

##### checkHandle()

```ts theme={null}
checkHandle(handle: string): Promise<boolean>;
```

Return whether the handle has been processed.

**Parameters**

| Parameter | Type     |
| --------- | -------- |
| `handle`  | `string` |

**Returns**

`Promise`\<`boolean`>

##### delete()

```ts theme={null}
delete(docId: string): Promise<string>;
```

Delete a file from the dataset.

**Parameters**

| Parameter | Type     |
| --------- | -------- |
| `docId`   | `string` |

**Returns**

`Promise`\<`string`>

##### getMetadata()

```ts theme={null}
getMetadata(ids: string[], fields?: string[]): Promise<Record<string, Record<string, any>>>;
```

Get metadata for one or more documents.

**Parameters**

| Parameter | Type        |
| --------- | ----------- |
| `ids`     | `string`\[] |
| `fields?` | `string`\[] |

**Returns**

`Promise`\<`Record`\<`string`, `Record`\<`string`, `any`>>>

##### list()

```ts theme={null}
list(fields?: string[], filter?: LogicalExpression): DatasetListStream;
```

List files in the dataset as an async iterator.

**Parameters**

| Parameter | Type                                                                  |
| --------- | --------------------------------------------------------------------- |
| `fields?` | `string`\[]                                                           |
| `filter?` | [`LogicalExpression`](/sdk/topk-js/Namespace.query#logicalexpression) |

**Returns**

[`DatasetListStream`](/sdk/topk-js/index#datasetliststream)

##### updateMetadata()

```ts theme={null}
updateMetadata(docId: string, metadata: Record<string, any>): Promise<string>;
```

Update metadata for a file.

**Parameters**

| Parameter  | Type                       |
| ---------- | -------------------------- |
| `docId`    | `string`                   |
| `metadata` | `Record`\<`string`, `any`> |

**Returns**

`Promise`\<`string`>

##### upsertFile()

```ts theme={null}
upsertFile(
   docId: string, 
   input: InputFile, 
metadata: Record<string, any>): Promise<string>;
```

Upsert a file to the dataset.

**Parameters**

| Parameter  | Type                                        |
| ---------- | ------------------------------------------- |
| `docId`    | `string`                                    |
| `input`    | [`InputFile`](/sdk/topk-js/index#inputfile) |
| `metadata` | `Record`\<`string`, `any`>                  |

**Returns**

`Promise`\<`string`>

##### waitForHandle()

```ts theme={null}
waitForHandle(handle: string, config?: WaitConfig): Promise<void>;
```

Poll until a handle has been processed or the timeout is reached.

Throws if the handle is not processed within the configured timeout.

**Parameters**

| Parameter | Type                                          |
| --------- | --------------------------------------------- |
| `handle`  | `string`                                      |
| `config?` | [`WaitConfig`](/sdk/topk-js/index#waitconfig) |

**Returns**

`Promise`\<`void`>

***

### DatasetListStream

Iterator for dataset list responses.

This type implements JavaScript's async iterable protocol.
It can be used with `for await...of` loops.

**See**

[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration\_protocols#the\_async\_iterator\_and\_async\_iterable\_protocols](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)

**Constructors**

**Constructor**

```ts theme={null}
new DatasetListStream(): DatasetListStream;
```

**Returns**

[`DatasetListStream`](/sdk/topk-js/index#datasetliststream)

**Methods**

##### \[asyncIterator]\()

```ts theme={null}
asyncIterator: AsyncGenerator<ListEntry, void, undefined>;
```

**Returns**

`AsyncGenerator`\<[`ListEntry`](/sdk/topk-js/index#listentry), `void`, `undefined`>

##### next()

```ts theme={null}
next(): Promise<ListEntry>;
```

Returns the next entry in the stream.

**Returns**

`Promise`\<[`ListEntry`](/sdk/topk-js/index#listentry)>

***

### DatasetsClient

**`Internal`**

Client for managing datasets.

**Methods**

##### create()

```ts theme={null}
create(name: string, description?: string): Promise<Dataset>;
```

Create a new dataset.

**Parameters**

| Parameter      | Type     |
| -------------- | -------- |
| `name`         | `string` |
| `description?` | `string` |

**Returns**

`Promise`\<[`Dataset`](/sdk/topk-js/index#dataset-1)>

##### delete()

```ts theme={null}
delete(name: string): Promise<void>;
```

Delete a dataset.

**Parameters**

| Parameter | Type     |
| --------- | -------- |
| `name`    | `string` |

**Returns**

`Promise`\<`void`>

##### get()

```ts theme={null}
get(name: string): Promise<Dataset>;
```

Get information about a specific dataset.

**Parameters**

| Parameter | Type     |
| --------- | -------- |
| `name`    | `string` |

**Returns**

`Promise`\<[`Dataset`](/sdk/topk-js/index#dataset-1)>

##### list()

```ts theme={null}
list(): Promise<Dataset[]>;
```

List all datasets.

**Returns**

`Promise`\<[`Dataset`](/sdk/topk-js/index#dataset-1)\[]>

##### update()

```ts theme={null}
update(name: string, params: UpdateDatasetParams): Promise<Dataset>;
```

Update dataset properties

**Parameters**

| Parameter | Type                                                            |
| --------- | --------------------------------------------------------------- |
| `name`    | `string`                                                        |
| `params`  | [`UpdateDatasetParams`](/sdk/topk-js/index#updatedatasetparams) |

**Returns**

`Promise`\<[`Dataset`](/sdk/topk-js/index#dataset-1)>

***

### SearchStream

Iterator for search responses.

This type implements JavaScript's async iterable protocol.
It can be used with `for await...of` loops.

**See**

[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration\_protocols#the\_async\_iterator\_and\_async\_iterable\_protocols](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)

**Constructors**

**Constructor**

```ts theme={null}
new SearchStream(): SearchStream;
```

**Returns**

[`SearchStream`](/sdk/topk-js/index#searchstream)

**Methods**

##### \[asyncIterator]\()

```ts theme={null}
asyncIterator: AsyncGenerator<SearchResult, void, undefined>;
```

**Returns**

`AsyncGenerator`\<[`SearchResult`](/sdk/topk-js/index#searchresult), `void`, `undefined`>

## Interfaces

### Answer

Represents a final answer in an ask response.

**Properties**

| Property                                    | Type                                                                   |
| ------------------------------------------- | ---------------------------------------------------------------------- |
| <a id="property-confidence" /> `confidence` | `number`                                                               |
| <a id="property-facts" /> `facts`           | [`Fact`](/sdk/topk-js/index#fact)\[]                                   |
| <a id="property-refs" /> `refs`             | `Record`\<`string`, [`SearchResult`](/sdk/topk-js/index#searchresult)> |

***

### 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.

**Properties**

| Property                                       | Type     | Description                                            |
| ---------------------------------------------- | -------- | ------------------------------------------------------ |
| <a id="property-base" /> `base?`               | `number` | Base multiplier for exponential backoff (default: 2.0) |
| <a id="property-initbackoff" /> `initBackoff?` | `number` | Initial delay before the first retry in milliseconds   |
| <a id="property-maxbackoff" /> `maxBackoff?`   | `number` | Maximum delay between retries in milliseconds          |

***

### Chunk

Text chunk content.

**Properties**

| Property                                | Type        |
| --------------------------------------- | ----------- |
| <a id="property-docpages" /> `docPages` | `number`\[] |
| <a id="property-text" /> `text`         | `string`    |

***

### ClientConfig

Configuration for the TopK client.

This struct contains all the necessary configuration options to connect to the TopK API.
The `api_key` and `region` are required, while other options have sensible defaults.

**Properties**

| Property                                       | Type                                            | Description                                                                                                                    |
| ---------------------------------------------- | ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| <a id="property-apikey" /> `apiKey`            | `string`                                        | Your TopK API key for authentication                                                                                           |
| <a id="property-host" /> `host?`               | `string`                                        | Custom host URL (optional, defaults to the standard TopK endpoint)                                                             |
| <a id="property-https" /> `https?`             | `boolean`                                       | Whether to use HTTPS (optional, defaults to true)                                                                              |
| <a id="property-region" /> `region`            | `string`                                        | The region where your data is stored. For available regions see: [https://docs.topk.io/regions](https://docs.topk.io/regions). |
| <a id="property-retryconfig" /> `retryConfig?` | [`RetryConfig`](/sdk/topk-js/index#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.

**Properties**

| Property                                  | Type                                                                                 | Description                                          |
| ----------------------------------------- | ------------------------------------------------------------------------------------ | ---------------------------------------------------- |
| <a id="property-createdat" /> `createdAt` | `string`                                                                             | Timestamp when the collection was created (ISO 8601) |
| <a id="property-name" /> `name`           | `string`                                                                             | Name of the collection                               |
| <a id="property-orgid" /> `orgId`         | `string`                                                                             | Organization ID that owns the collection             |
| <a id="property-projectid" /> `projectId` | `string`                                                                             | Project ID that contains the collection              |
| <a id="property-region-1" /> `region`     | `string`                                                                             | Region where the collection is stored                |
| <a id="property-schema" /> `schema`       | `Record`\<`string`, [`CollectionFieldSpec`](/sdk/topk-js/index#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.

**Properties**

| Property                                | Type              | Description                                                      |
| --------------------------------------- | ----------------- | ---------------------------------------------------------------- |
| <a id="property-datatype" /> `dataType` | `DataType`        | Data type of the field                                           |
| <a id="property-index" /> `index?`      | `FieldIndexUnion` | Index configuration for the field (optional)                     |
| <a id="property-required" /> `required` | `boolean`         | Whether the field is required (must be present in all documents) |

***

### Content

Content in a search result. One of chunk, page, or image.

**Properties**

| Property                        | Type                                                                                                               |
| ------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| <a id="property-data" /> `data` | \| [`Chunk`](/sdk/topk-js/index#chunk) \| [`Page`](/sdk/topk-js/index#page) \| [`Image`](/sdk/topk-js/index#image) |
| <a id="property-type" /> `type` | `"page"` \| `"image"` \| `"chunk"`                                                                                 |

***

### Dataset

Represents a dataset in the TopK service.

**Properties**

| Property                                       | Type     | Description                                     |
| ---------------------------------------------- | -------- | ----------------------------------------------- |
| <a id="property-createdat-1" /> `createdAt`    | `string` | RFC 3339 timestamp when the dataset was created |
| <a id="property-description" /> `description?` | `string` | Dataset description                             |
| <a id="property-name-1" /> `name`              | `string` | Name of the dataset                             |
| <a id="property-orgid-1" /> `orgId`            | `string` | Organization ID that owns the dataset           |
| <a id="property-projectid-1" /> `projectId`    | `string` | Project ID that contains the dataset            |
| <a id="property-region-2" /> `region`          | `string` | Region where the dataset is stored              |

***

### Fact

Represents a fact in an ask response.

**Properties**

| Property                            | Type        |
| ----------------------------------- | ----------- |
| <a id="property-fact" /> `fact`     | `string`    |
| <a id="property-refids" /> `refIds` | `string`\[] |

***

### Image

Image content.

**Properties**

| Property                                | Type        |
| --------------------------------------- | ----------- |
| <a id="property-data-1" /> `data`       | `number`\[] |
| <a id="property-mimetype" /> `mimeType` | `string`    |

***

### InputFile

Input for upserting a file to a dataset.

Provide either a `path` to a file on disk, or inline data via `data` + `fileName` + `mimeType`.

**Properties**

| Property                                   | Type     | Description                                                              |
| ------------------------------------------ | -------- | ------------------------------------------------------------------------ |
| <a id="property-data-2" /> `data?`         | `Buffer` | Inline file data as a Buffer.                                            |
| <a id="property-filename" /> `fileName?`   | `string` | File name (required when using inline `data`).                           |
| <a id="property-mimetype-1" /> `mimeType?` | `string` | MIME type (required when using inline `data`).                           |
| <a id="property-path" /> `path?`           | `string` | Path to a file on disk. If provided, fileName and mimeType are inferred. |

***

### ListEntry

Entry in a dataset.

**Properties**

| Property                                         | Type                       |
| ------------------------------------------------ | -------------------------- |
| <a id="property-id" /> `id`                      | `string`                   |
| <a id="property-metadata" /> `metadata`          | `Record`\<`string`, `any`> |
| <a id="property-mimetype-2" /> `mimeType`        | `string`                   |
| <a id="property-name-2" /> `name`                | `string`                   |
| <a id="property-size" /> `size`                  | `number`                   |
| <a id="property-status" /> `status`              | `string`                   |
| <a id="property-statusreason" /> `statusReason?` | `string`                   |

***

### Page

Page content with optional image.

**Properties**

| Property                                    | Type                                |
| ------------------------------------------- | ----------------------------------- |
| <a id="property-image" /> `image?`          | [`Image`](/sdk/topk-js/index#image) |
| <a id="property-pagenumber" /> `pageNumber` | `number`                            |

***

### Progress

Represents a progress update in an ask response.

**Properties**

| Property                            | Type     |
| ----------------------------------- | -------- |
| <a id="property-update" /> `update` | `string` |

***

### QueryOptions

Options for query operations.

These options control the behavior of query operations, including consistency
guarantees and sequence number constraints.

**Properties**

| Property                                       | Type                                                      | Description                                        |
| ---------------------------------------------- | --------------------------------------------------------- | -------------------------------------------------- |
| <a id="property-consistency" /> `consistency?` | [`ConsistencyLevel`](/sdk/topk-js/index#consistencylevel) | Consistency level for the query                    |
| <a id="property-lsn" /> `lsn?`                 | `string`                                                  | Last sequence number to query at (for consistency) |

***

### RetryConfig

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.

**Properties**

| Property                                     | Type                                                | Description                                              |
| -------------------------------------------- | --------------------------------------------------- | -------------------------------------------------------- |
| <a id="property-backoff" /> `backoff?`       | [`BackoffConfig`](/sdk/topk-js/index#backoffconfig) | Backoff configuration for spacing out retry attempts     |
| <a id="property-maxretries" /> `maxRetries?` | `number`                                            | Maximum number of retries to attempt before giving up    |
| <a id="property-timeout" /> `timeout?`       | `number`                                            | Total timeout for the entire retry chain in milliseconds |

***

### SearchResult

Represents a search result in an ask response.

**Properties**

| Property                                  | Type                                    |
| ----------------------------------------- | --------------------------------------- |
| <a id="property-content" /> `content?`    | [`Content`](/sdk/topk-js/index#content) |
| <a id="property-contentid" /> `contentId` | `string`                                |
| <a id="property-dataset" /> `dataset`     | `string`                                |
| <a id="property-docid" /> `docId`         | `string`                                |
| <a id="property-docname" /> `docName`     | `string`                                |
| <a id="property-doctype" /> `docType`     | `string`                                |
| <a id="property-metadata-1" /> `metadata` | `Record`\<`string`, `any`>              |

***

### UpdateDatasetParams

**Properties**

| Property                                         | Type     | Description         |
| ------------------------------------------------ | -------- | ------------------- |
| <a id="property-description-1" /> `description?` | `string` | Dataset description |

***

### WaitConfig

Configuration for polling when waiting for a handle to be processed.

**Properties**

| Property                                           | Type     | Description                                                         |
| -------------------------------------------------- | -------- | ------------------------------------------------------------------- |
| <a id="property-frequencysecs" /> `frequencySecs?` | `number` | How often to poll for the handle status, in seconds. Default is 5.  |
| <a id="property-timeoutsecs" /> `timeoutSecs?`     | `number` | Maximum time to wait before timing out, in seconds. Default is 300. |

## Namespaces

* [data](/sdk/topk-js/Namespace.data)
* [query](/sdk/topk-js/Namespace.query)
* [query\_fn](/sdk/topk-js/Namespace.query_fn)
* [schema](/sdk/topk-js/Namespace.schema)

## Type Aliases

### ConsistencyLevel

```ts theme={null}
type ConsistencyLevel = "indexed" | "strong";
```

Consistency levels for query operations.

* `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)

***

### Mode

```ts theme={null}
type Mode = "auto" | "summarize" | "research";
```

Mode for ask operations.
