# `jadpo search`

Rebuild a search index.

Rebuilds the index an engine keeps an entity's words in, from the entity's records (area 16, "An engine instead of PostgreSQL"): `reindex <Entity>` sends each record's document through the connection its `search:` names, as the app keeps it after each commit, its searched fields and tenancy reference and nothing else, and reads it again once the engine has answered, so a record that changed or was erased meanwhile is sent again or taken out. A record erased before is gone, so it is never sent. The engine's address and credential are the connection's settings, read as jadpo dev reads them; the database is the one --url names, else the store's connection's setting, else a running jadpo dev's. It stops at the first refusal, saying how many were sent; sending a record again changes nothing, so it can be run again.

```text
jadpo search <action> [entity]
```

## Arguments

- `action`: What to do: reindex
- `entity` (optional): The entity whose index to rebuild

## Flags

- `--url <url>`: The database the entity's records are in

## On every command

- `--json`: Print data for tools instead of text
- `--full`: Show everything a report shortens
- `--help`: Show every flag, with examples
- `--color <when>`: Choose when to use colour

`jadpo search --json` writes one JSON document to standard output instead of text, with the same exit code. The document has `schemaVersion`, `command` (`"search"`), `ok`, `data` (what the command produced, `null` when it failed) and `diagnostics` (each error with its `rule`, `reason`, `next` and `help`). A command that needs a terminal refuses `--json` and names the flags that do the same job.

## Examples

```text
# Rebuild the products' index after emptying it
jadpo search reindex Product
```

## Errors

- [`cli.search_arguments`](/docs/errors/cli.search_arguments.md): A `jadpo search` command names no action or one it doesn't have, or an entity the project doesn't declare or doesn't search in an engine
- [`search.reindex_failed`](/docs/errors/search.reindex_failed.md): An entity's index couldn't be rebuilt in its engine, because nothing sets the engine's settings, the database or the engine can't be reached, or the engine refused a record
- [`toolchain.project_not_found`](/docs/errors/toolchain.project_not_found.md): You ran a command that works on a project in a folder with no `app.jadpo`, in it or in any folder above it
