﻿---
title: Commands
description: Paths are relative to the current folder, and each command that reads a configuration takes --config (default judy.yaml in the current folder). Exit codes:...
url: https://docs-v3-preview.elastic.dev/reference/commands
---

# Commands
```text
judy <command> [options]
judy --help          list the commands
judy <command> --help
judy --version
```

Paths are relative to the current folder, and each command that reads a configuration takes `--config` (default `judy.yaml` in
the current folder). Exit codes: 0 ok, 1 a gate breached or a comparison regressed, 2 usage or an invalid file, 3 an IO error or
failed searches.

## `judy run <set>`

Runs a judgement set against a target and prints the scorecard. Writes `{set}.{target}.results.yaml` next to the set and, when
judy built the request, `{set}.{target}.requests.jsonl`. Appends markdown to `$GITHUB_STEP_SUMMARY` when it is set.

| Option                    | Meaning                                                                                                                   |
|---------------------------|---------------------------------------------------------------------------------------------------------------------------|
| `--target <name>`         | **required.** A target from `judy.yaml`, optionally `name:key=value,key=value` to override parameters                     |
| `--config <file>`         | the configuration file                                                                                                    |
| `--output <folder>`       | where to write the results file (default: the set's folder)                                                               |
| `--format text\|md\|json` | the output (default `text`)                                                                                               |
| `--labels all\|human`     | `all` counts cached LLM labels where no human rating exists; `human` ignores them                                         |
| `--k <n>`                 | the depth, overriding the set's                                                                                           |
| `--concurrency <n>`       | how many queries run at once (default 4)                                                                                  |
| `--no-explain`            | leave out the [plain-words reading](https://docs-v3-preview.elastic.dev/concepts/reading-output) that follows the numbers |


## `judy compare <baseline> <candidate>`

Each side is a results file, or a target name (`name:key=value` runs it with a parameter changed). Per-query deltas, wins and
losses, the most improved and regressed queries and a paired randomization test. See [Comparing changes](https://docs-v3-preview.elastic.dev/workflow/compare).

| Option                    | Meaning                                                                                          |
|---------------------------|--------------------------------------------------------------------------------------------------|
| `--set <file>`            | the judgement set; needed when a side is a target                                                |
| `--config <file>`         | the configuration file                                                                           |
| `--metric <kind@k>`       | the metric to compare (default: the baseline's nDCG)                                             |
| `--labels all\|human`     | for sides run now                                                                                |
| `--max-regression <n>`    | exit 1 when the candidate's mean is lower by more than `n`                                       |
| `--format text\|md\|json` | the output                                                                                       |
| `--concurrency <n>`       | how many queries run at once                                                                     |
| `--no-explain`            | leave out the [plain-words reading](https://docs-v3-preview.elastic.dev/concepts/reading-output) |


## `judy modes <set>`

Compares retrieval modes query by query. See [Modes](https://docs-v3-preview.elastic.dev/concepts/modes).

| Option                                              | Meaning                                                                                          |
|-----------------------------------------------------|--------------------------------------------------------------------------------------------------|
| `--target <name>`                                   | **repeatable.** A target that retrieves one way                                                  |
| `--router <name>`                                   | a target that chooses its mode per query, usually a builder                                      |
| `--config`, `--metric`, `--labels`, `--concurrency` | as for `compare`                                                                                 |
| `--format text\|json`                               | the output                                                                                       |
| `--no-explain`                                      | leave out the [plain-words reading](https://docs-v3-preview.elastic.dev/concepts/reading-output) |


## `judy judge <set>`

Has the LLM label the unjudged documents a target returns, into `{set}.llm.yaml`. The model sees the query, the intent and the
document text, never the request, scores or ranks. See [the judge](https://docs-v3-preview.elastic.dev/llm/judging).

| Option                      | Meaning                                                          |
|-----------------------------|------------------------------------------------------------------|
| `--target <name>`           | **required.** The target to search with                          |
| `--max-calls <n>`           | the most model calls to make (default 200)                       |
| `--dry-run`                 | say how many documents and calls it would take, and send nothing |
| `--provider`, `--model`     | the LLM, overriding `judy.yaml`                                  |
| `--config`, `--concurrency` | as above                                                         |


## `judy review <set>`

Reviews LLM labels one by one: approve (it then counts as a human rating), reject (it is ignored and not asked again) or skip.

## `judy diagnose <set>`

Has an LLM say why the worst queries rank their relevant documents badly. It sees the request, what came back, the judged documents
that did not and the index mapping and settings. Writes `{set}.{target}.diagnosis.md`. See
[Diagnose](https://docs-v3-preview.elastic.dev/llm/diagnose) and [suggest](https://docs-v3-preview.elastic.dev/llm/suggest).

| Option                                                           | Meaning                                           |
|------------------------------------------------------------------|---------------------------------------------------|
| `--target <name>`                                                | **required.** The target to run                   |
| `--query <id>`                                                   | **repeatable.** Only diagnose these query ids     |
| `--max-queries <n>`                                              | how many of the worst queries to send (default 5) |
| `--metric <kind@k>`                                              | the metric that ranks the queries (default nDCG)  |
| `--dry-run`                                                      | say what would be sent, and send nothing          |
| `--no-index-info`                                                | do not send the index mapping and settings        |
| `--provider`, `--model`, `--output`, `--config`, `--concurrency` | as above                                          |


## `judy suggest <set>`

An LLM proposes variants of a `dsl` or `esql` target's template. judy runs each against the set and compares it with the
current one. It tests on the queries the model saw and on a held-out share.

| Option                                                           | Meaning                                                                 |
|------------------------------------------------------------------|-------------------------------------------------------------------------|
| `--target <name>`                                                | **required.** A `dsl` or `esql` target                                  |
| `--variants <n>`                                                 | how many variants to ask for (default 3)                                |
| `--max-queries <n>`                                              | how many of the worst training queries the model sees (default 8)       |
| `--holdout <fraction>`                                           | the share kept from the model, chosen by a hash of the id (default 0.3) |
| `--metric <kind@k>`                                              | the metric to improve (default nDCG)                                    |
| `--dry-run`, `--no-index-info`                                   | as for `diagnose`                                                       |
| `--provider`, `--model`, `--output`, `--config`, `--concurrency` | as above                                                                |


## `judy synthesize <corpus>`

An LLM writes search queries for the documents of a corpus file (JSON lines, or an Elasticsearch bulk file). judy builds a
set in which each document is the perfect answer to its own queries. Each query is tagged `style:keyword` or
`style:question`.

| Option                                               | Meaning                                                             |
|------------------------------------------------------|---------------------------------------------------------------------|
| `--id <field>`                                       | the field holding the document id (default `id`)                    |
| `--title <field>`                                    | the field holding the title                                         |
| `--text <field>`                                     | **repeatable.** The fields holding the text                         |
| `--per-doc <n>`                                      | how many queries per document (default 2)                           |
| `--max-docs <n>`                                     | how many documents to use, sampled by a hash of the id (default 50) |
| `--name <name>`                                      | the set's name (default: the corpus file's name)                    |
| `--output <file>`                                    | the file to write (default `{name}.judgements.yaml`)                |
| `--k <n>`                                            | the depth the set measures at (default 10)                          |
| `--dry-run`                                          | say how many calls it would make                                    |
| `--provider`, `--model`, `--config`, `--concurrency` | as above                                                            |


## `judy import`


| Command                      | Converts                                                                                                                                                                          |
|------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `judy import wands`          | the WANDS example dataset: downloads it, writes `wands.judgements.yaml`, and with `--cluster` or `--url` creates an index and loads the products. See [below](#judy-import-wands) |
| `judy import trec`           | TREC topics and qrels into a judgement set                                                                                                                                        |
| `judy import docs-builder`   | a folder of docs-builder relevance sets (`*.json`) into judgement sets; a floor becomes gates                                                                                     |
| `judy import website-search` | website-search's `judgements.csv` into a judgement set                                                                                                                            |


## `judy export`


| Command            | Writes                                                                                                     |
|--------------------|------------------------------------------------------------------------------------------------------------|
| `judy export trec` | a judgement set's topics and qrels in TREC format                                                          |
| `judy export run`  | the run behind a results file, in `trec_eval`'s format, to check judy's numbers with `trec_eval` or `ranx` |


### `judy import wands`

[WANDS](https://github.com/wayfair/WANDS) is Wayfair's product search dataset (MIT licence): 480 judged queries and 42,994 products.
judy uses it as an example; everything else works against your own index, alias or data stream.
```sh
judy import wands --cluster live --index wands
```

With no folder judy downloads the three files at the commit it was built against. It converts the judgements (Exact is grade 3,
Partial 1, Irrelevant 0). When you name a cluster, judy creates the index and bulk loads the products. The index has a `semantic_text` field
`product_semantic`, fed from the name, class and description.

| Option                           | Meaning                                                                                                |
|----------------------------------|--------------------------------------------------------------------------------------------------------|
| `<directory>`                    | a folder that already holds `query.csv`, `label.csv` and `product.csv`, instead of downloading         |
| `--commit <ref>`                 | a commit, tag or branch of `wayfair/WANDS` to download (default: the one judy was built against)       |
| `--output <folder>`              | where to write `wands.judgements.yaml` (default: the current folder)                                   |
| `--cluster <name>`               | a cluster from `judy.yaml` to load the products into                                                   |
| `--url <url>`, `--api-key <key>` | a cluster without a configuration file. Both accept `env:NAME`                                         |
| `--config <file>`                | the configuration file for `--cluster`                                                                 |
| `--index <name>`                 | the index to create (default `judy-wands`)                                                             |
| `--no-semantic`                  | leave out the `semantic_text` field, so loading runs no inference and is much faster                   |
| `--inference-id <id>`            | the inference endpoint for the `semantic_text` field (default: the cluster's default)                  |
| `--recreate`                     | delete the index first when it exists. Without it an existing index is an error and nothing is changed |

Without `--cluster` or `--url` judy writes the products to `wands.products.ndjson` instead, for you to load yourself.