# Runbook — Typo-tolerant autocomplete / "did you mean" in Manticore

Manticore is **not** Elasticsearch and **not** plain SQL. There is no completion/term
suggester in a JSON `_search` body, and no `LIKE` / `SOUNDEX` on a full-text field.
Fuzzy word suggestions come from a built-in command — **`CALL SUGGEST` / `CALL QSUGGEST`** —
that returns the stored keywords closest (by edit distance) to a misspelled input.

Talk to searchd with the MySQL client: `mysql -h127.0.0.1 -P9306`.

## The one requirement people miss: an infix keyword dictionary
`CALL SUGGEST` works **only** on a table whose keyword dictionary keeps infixes. If you
create a default table, `CALL SUGGEST` errors with *"suggests work only for keywords
dictionary with infix enabled."* So set **`min_infix_len`** (or `min_prefix_len`) at
CREATE time:

```sql
CREATE TABLE colors(name text) min_infix_len='2';
INSERT INTO colors(id,name) VALUES (1,'purple'),(2,'orange'),(3,'magenta');
```

## Ask for suggestions
```sql
CALL SUGGEST('purpel','colors');     -- misspelling -> returns 'purple'
CALL QSUGGEST('oragne','colors');    -- QSUGGEST is the same, tuned for last-word autocomplete
```
The result set has columns `suggest`, `distance`, `docs` — the `suggest` column is the
corrected word. `CALL SUGGEST('<word>','<table>')` is a command, not a `SELECT`.

## Pitfalls this runbook prevents
- Reaching for an Elasticsearch completion/term/phrase **suggester** in a JSON request body.
- Trying `WHERE name LIKE '%...%'` or a SOUNDEX/edit-distance UDF — `LIKE` is a syntax
  error on a full-text field, and there is no built-in fuzzy SQL operator.
- Creating a **default** table and calling SUGGEST on it (errors — no infix dictionary).
- Assuming you must precompute suggestions yourself; `CALL SUGGEST` does the edit-distance
  matching against the table's keyword dictionary for you.
