Quickstart
Log in, write and filter vectors, then verify the same index after a restart.
Skeg 0.8 · Development documentation
Start a local Skeg server that requires a login. Create a durable index, add vectors with metadata, then update one row and delete another. After a restart, check that the same index contains the updated row and that the deleted row is still absent.
Prepare the exercise
Install Skeg 0.8 and install the CLI. The CLI creates the logins even if you use Python or Rust for the example.
cargo install skeg-cli --version 0.2.0 --locked
Use two terminals, a POSIX shell, and openssl. The CLI example also uses awk. For Python, use Python 3.10 or newer with venv support. For Rust, use a toolchain that supports edition 2024.
In the first terminal, create a fresh directory and generate separate passwords for the administrator and the application user. The subshell restricts access to the password files.
exercise=$(mktemp -d)
printf 'Exercise directory: %s\n' "$exercise"
cd "$exercise"
(umask 077; openssl rand -hex 16 > root.pw; openssl rand -hex 16 > ana.pw)
skeg-cli auth init --store auth.kdb --admin-user root --admin-tenant ops --password-file root.pw
skeg-cli auth user create --store auth.kdb --user ana --tenant acme --password-file ana.pw
The example logs in as ana in tenant acme. The administrator belongs to tenant ops.
Start the server
In the first terminal, run the server in the foreground. The listen address keeps it local, and strict mode requires every connection to log in.
skeg --data-dir ./data --addr 127.0.0.1:6379 --protocol resp3 \
--tenant-auth ./auth.kdb --tenant-strict --admin-tenant ops
In the second terminal, change to the exercise directory printed earlier and set the connection details:
export SKEG_CLIENT__ADDR=127.0.0.1:6379
export SKEG_CLIENT__USER=ana
export SKEG_CLIENT__PASSWORD_FILE="$PWD/ana.pw"
Write and search
Choose one client. Each example creates the same index and checks the same writes, search filters, update and deletion.
Command line
Download quickstart.sh into the exercise directory, then run:
sh quickstart.sh write
Python
Download quickstart.py into the exercise directory. Install the client in a virtual environment and run the example:
python3 -m venv .venv
. .venv/bin/activate
python -m pip install skeg==0.3.0
python quickstart.py write
Rust
Create a rust/src directory in the exercise directory. Save Cargo.toml as rust/Cargo.toml and main.rs as rust/src/main.rs. From the exercise directory, run:
cargo run --manifest-path rust/Cargo.toml -- write
Read the result
The example creates docs with eight dimensions, the tq2 tier, and durable disk storage. It inserts six rows with lang and year payload fields. The initial lang = it filter returns IDs 2, 4 and 6. The example changes row 3 to lang=it year=2030 and deletes row 4. The filter then returns IDs 2, 3 and 6.
The write step saves the index’s incarnation in quickstart.incarnation. An incarnation identifies a particular index. Creating another index with the same name produces a different incarnation. The step ends with write ok.
Restart and check the data
Stop Skeg with Ctrl+C in the first terminal and wait for the process to exit. Run the same server command again from the same directory. Keep ./data and ./auth.kdb in place.
In the second terminal, run the check step for the client you chose:
| Client | Command |
|---|---|
| Command line | sh quickstart.sh check |
| Python | python quickstart.py check |
| Rust | cargo run --manifest-path rust/Cargo.toml -- check |
The check opens the existing index, compares its incarnation with the saved value, and checks the vectors, the updated payload, and the deletion. The filtered result for lang = it still contains IDs 2, 3 and 6. The step ends with check ok.
Troubleshooting and cleanup
| Symptom | What to check |
|---|---|
| Address already in use | Choose a free port in the server command and use it in SKEG_CLIENT__ADDR. |
| Login refused | Check that the server opened auth.kdb from this exercise and that the client uses ana and ana.pw. The password file must be readable only by its owner. |
| Index or incarnation mismatch | Check the server’s data directory and the client’s working directory. Run write and check from the same directory so the check reads the saved incarnation. |
Index already exists during write | Start in a fresh exercise directory. Use check to verify an exercise that has already completed the write step. |
When finished, stop the server and leave the exercise directory in both terminals. Remove only that temporary directory if you want to discard the data and credentials.
For a smaller introduction, see Your first search. For a network deployment, see Authentication and tenants and Deployment.