Skip to main content
Command-line interface for TopK.

Installation

Quick start

topk import discovers a schema, shows the plan, and imports on confirmation — see import.

Authentication

To authenticate, run:

Commands

login

Log in with TopK CLI:
Over SSH or in a container, use topk login --no-browser. Log in from any browser with the URL it prints, then paste the login code into the terminal.

logout

Remove the saved session:

project

list

List projects in the current organization.
topk project list marks the currently selected project with *.

select

Select a default project.

clear

Clear the selected project:

current

Show the currently selected project.

get

Get a project by ID.

create

Create a project.

delete

Delete a project by ID.

region

list

List available regions.
topk region list marks the currently selected region with *.

select

Select a default region.

clear

Clear the selected region:

current

Show the currently selected region.

sql

Create and manage collections, read and write documents, and run keyword, vector, and semantic searches with TopK SQL.

Run a query

Log in and find your project ID, then run SQL against a collection. This example searches a title field with a semantic index:
See the TopK SQL reference for complete documentation.

Run SQL from a file or stdin

Inspect tables

psql-style commands list and describe tables:

Output

Results print as one table per statement by default, with row counts on stderr. Use -o json to stream one JSON object per row as it arrives, for example topk sql … -o json | jq. Pipe long output to a pager yourself, for example | less.

usage

Show usage of your organization, projects and collections over a time range.

Choose a time range

Durations count back from now.
When a date is passed, it starts at midnight UTC: 2026-10-01 is 2026-10-01T00:00:00Z.

Choose a scope

Without --project-id, usage covers your whole organization.

Metrics

import

Bulk import into a TopK collection. Every run previews the selected fields and asks before writing; a new collection is created with the first write, so a run that fails before writing leaves none behind.

Authenticate

Log in, then import:

Import a database

One import reads one table, collection or index into one collection. PostgreSQL, MySQL, SQLite and MongoDB require #object in the source URI; Elasticsearch requires an index path. For example, sqlite:./shop.db#orders or es://host/orders. Connection options precede the selector: postgres://host/db?sslmode=require#public.orders.

Import files

A source is one file or one glob. For a folder or a bucket prefix, use a glob such as 's3://bucket/books/*.parquet'. * matches files in one folder; ** also matches subfolders ('s3://bucket/books/**/*.parquet').
A {name} folder in a glob matches like * and gives each row a text column name holding that folder’s name; key=value folders add a key column the same way. Path columns work for data files (csv, tsv, json, jsonl, parquet, arrow, avro) in local paths and buckets, not http(s)://, and can be used in --partition, --id, -f and --filter. A name the files already use as a column is refused. To match a folder literally named {name}, write [{]name}.

Copy a TopK collection

A copy onto the source collection itself is refused. The source region is resolved from the source collection. --region selects the destination region. Schema and indexes copy as-is, and fields the source does not declare copy too; the copy is additive. Sources with named partitions are rejected before the destination is created; partitioned collection copies are not supported.

Split rows across partitions

Each row goes to the partition named by that column, so one source stream writes into as many partitions as the column has values.
The column only has to exist in the source. It does not have to be an imported field.

Select fields and indexes

Every column is imported. -f sets a field’s type or index, and --exclude leaves fields out. Both use names after --rename; --exclude also accepts the source column name. A column with no TopK type, such as a list of booleans, structs or timestamps, fails the plan until it is excluded, or given a type with -f where one applies. The document ID is always read separately. A field name cannot start with _, so a source field such as _lang imports as lang and the plan shows lang ← _lang; --rename gives it another name. For MongoDB, Elasticsearch and TopK sources, a field outside the plan, such as one the discovery sample or the index mapping missed, is written as read; --exclude, -f and --rename accept such fields, and an existing collection’s declared fields are read from each row, so a row without a required one fails. Files and databases list every column, so a name that is not a column is an error. A semantic index on text shortens stored values over 32,768 characters; the preview warns about this. Other text is not shortened.

Resume a stopped run

Stop a run — ^C, a lost connection — and pick it up where it left off:
Resume continues from the last source checkpoint, after all preceding partition writes succeeded. Limits include rows consumed before the checkpoint, including skipped rows. A resumed run keeps its --concurrency, --batch-bytes and --continue-on-error; pass one again to change it. Without --resume, a re-run re-imports everything — upserts are idempotent. MongoDB checkpoints use the source _id, independently of the destination ID mapping. Legacy checkpoints made with a custom ID column require a new import. Elasticsearch retains its point-in-time snapshot for interrupted scans and closes it before returning a final page.

Sources

SQL column names are literal, including dots. Dots inside schema or table names are not supported; source discovery rejects them explicitly. For a new collection, discovery takes the source’s types; an explicit field choice can change its type or add an index. A collection’s schema is set when it is created: for an existing collection, declared fields use its types and indexes, explicit choices must match them, and other fields are written without a declaration. An index on a field the collection does not declare, and a declared required field the source lacks, fail the plan. Dry-run resolves against the destination too, so it requires a project and authentication. vector, matrix, and sparse preserve an already typed source field. Without a choice, a list of floats in a file imports as float_list. Float lists, text ("[1,2,3]"), and packed bytes become f32 vectors with -f embedding=vector:768:cosine. A sparse vector reads numeric keys or parallel indices/values lists. A value converts exactly or its row fails, except for these conversions: Image fields accept JPEG/PNG bytes, data URIs, and Hugging Face {bytes, path} structs. Each image must fit within 512 KiB. Select an already typed image with -f page=semantic. For a data URI or image bytes, use -f page=image:semantic to convert and index it.

Failures and limits

Pending document buffers are bounded by --batch-bytes × --concurrency, independently of in-flight writes and source read-ahead. Under pressure, the importer sends individual partial batches to free space. Progress counts acknowledged writes. After 10 seconds without progress, the CLI prints a waiting notice. By default, a row decoding, conversion, or document-validation failure stops the import. --continue-on-error skips these rows. CSV uses DuckDB’s inferred types and date formats; reader parsing and type-conversion errors stop the import even with --continue-on-error. If the destination rejects a batch for document validation, the importer retries its documents individually and skips only those rejected. Connection, authentication, query, and stream failures still stop the import after normal retries. Summaries count acknowledged writes and skipped rows for the current invocation. Every skipped row is listed once in <run>.rejected.jsonl next to the run state, with its row number in source order, document ID, field and error; the terminal shows the first three, and the count and path of the file for the whole run. A run that completes exits 0, with or without skipped rows; a fatal error exits 1. If the run state cannot be saved, the import stops. Progress counts acknowledged writes for this invocation. Checkpoints advance only after preceding rows are written or skipped. Skips are final for that run: --resume does not revisit checkpointed skips. Resuming an interrupted import can replay writes after its last saved checkpoint; upserts replace documents with the same ID. Use a new import to retry corrected rows.
  • there is no schema migration: choices that differ from an existing collection’s declared fields are rejected
  • an upsert replaces the whole document, so --exclude on an existing field clears it

Exit codes

Global flags

These flags are accepted by every command:

--output

Options:
  • text (default)
  • json

Updating the CLI

To update CLI to the latest version, run: