# First Search

Register a database, start the daemon, drop a file into the inbox, and query it over the read-only HTTP API.

## Register a database

```bash
kura add my_docs
```

This command:

1. Collapses whitespace in the name into underscores.
2. Creates `~/.config/kuradb/my_docs/inbox/`.
3. Creates `~/Kura_my_docs` as a symlink to the inbox.
4. Registers `my_docs` in `~/.config/kuradb/db.json`.

The command fails when the name is already registered or `~/.config/kuradb/my_docs` already exists. A database added while the daemon is running is not hot-loaded; restart KuraDB before querying it.

## Start the daemon

```bash
kura
```

The foreground launcher starts a detached `--daemon` process and waits up to 10 seconds for the endpoint file. When ready, it prints a URL such as:

```text
http://localhost:43127
```

The daemon loads registered databases, restores caches from SQLite, starts a watcher and an embedding loop for each loaded database, and binds the read-only HTTP API to `127.0.0.1`. If the endpoint file does not appear in time, the launcher exits with an error that points at `~/.config/kuradb/daemon.log`.

## Index a file

```bash
cp document.md ~/Kura_my_docs/
```

The watcher polls every 10 seconds. Changed files are parsed and written to SQLite; the embedding scheduler polls every 5 seconds and processes at most 64 pending chunks per batch. Keyword search sees a chunk once it is written; semantic search sees it after it is embedded.

## Run a search

Read the selected endpoint and query both strategies:

```bash
BASE="$(cat ~/.config/kuradb/endpoint)"
curl "$BASE/api/search?db=my_docs&q=what+is+RAG&limit=5"
```

Use `target=keyword` or `target=semantic` to run only one strategy:

```bash
curl "$BASE/api/search?db=my_docs&q=vector+cache&target=semantic"
```

See [Search API](/api-reference-search) for every parameter and the response shape.
