# Typo Tolerance
URL: /docs/typo-tolerance

How Tachyon matches misspelled queries, and how to tune it.



Tachyon tolerates typos using Damerau-Levenshtein edit distance, with the
allowed number of edits scaled to query-token length so short words aren't
matched too loosely.

## Collection-level configuration [#collection-level-configuration]

Set at collection creation time, under `typo_tolerance` in the schema:

```json
{
  "typo_tolerance": {
    "enabled": true,
    "one_typo_min_len": 4,
    "two_typo_min_len": 8,
    "max_typos": 2
  }
}
```

| Field              | Default | Meaning                                             |
| ------------------ | ------- | --------------------------------------------------- |
| `enabled`          | `true`  | Whether typo tolerance is applied at all            |
| `one_typo_min_len` | `4`     | Token length at which 1 typo becomes allowed        |
| `two_typo_min_len` | `8`     | Token length at which 2 typos become allowed        |
| `max_typos`        | `2`     | Hard ceiling on allowed edits, regardless of length |

<Tabs items="['cURL', 'TypeScript', 'Python', 'C#']">
  <Tab value="cURL">
    ```bash
    curl -X POST localhost:8108/collections \
      -H 'Content-Type: application/json' \
      -d '{
        "name": "products",
        "fields": [{"name": "title", "type": "text"}],
        "typo_tolerance": {
          "enabled": true,
          "one_typo_min_len": 4,
          "two_typo_min_len": 8,
          "max_typos": 2
        }
      }'
    ```
  </Tab>

  <Tab value="TypeScript">
    ```ts
    import { Tachyon } from 'tachyon-sdk';

    const client = new Tachyon({ url: 'http://localhost:8108' });

    await client.collections.create({
      name: 'products',
      fields: [{ name: 'title', type: 'text' }],
      typo_tolerance: {
        enabled: true,
        one_typo_min_len: 4,
        two_typo_min_len: 8,
        max_typos: 2,
      },
    });
    ```
  </Tab>

  <Tab value="Python">
    ```python
    from tachyon_sdk import Tachyon

    client = Tachyon(url="http://localhost:8108")

    client.collections.create({
        "name": "products",
        "fields": [{"name": "title", "type": "text"}],
        "typo_tolerance": {
            "enabled": True,
            "one_typo_min_len": 4,
            "two_typo_min_len": 8,
            "max_typos": 2,
        },
    })
    ```
  </Tab>

  <Tab value="C#">
    ```csharp
    using Tachyon.Sdk;

    var client = new TachyonClient(new TachyonClientOptions { Url = "http://localhost:8108" });

    await client.Collections.CreateAsync(new CollectionSchema
    {
        Name = "products",
        Fields = [new FieldSchema { Name = "title", Type = FieldType.Text }],
        TypoTolerance = new TypoToleranceConfig
        {
            Enabled = true,
            OneTypoMinLen = 4,
            TwoTypoMinLen = 8,
            MaxTypos = 2,
        },
    });
    ```
  </Tab>
</Tabs>

A token shorter than `one_typo_min_len` must match exactly. Between
`one_typo_min_len` and `two_typo_min_len`, one edit is allowed. At or above
`two_typo_min_len`, two edits are allowed — capped by `max_typos`.

## Per-query override [#per-query-override]

A single query can only toggle typo tolerance on or off — the length
thresholds are fixed at the collection level and can't be overridden per
request:

<Tabs items="['cURL', 'TypeScript', 'Python', 'C#']">
  <Tab value="cURL">
    ```bash
    curl 'localhost:8108/collections/products/search?q=keyboard&typo_tolerance=false'
    ```
  </Tab>

  <Tab value="TypeScript">
    ```ts
    import { Tachyon } from 'tachyon-sdk';

    const client = new Tachyon({ url: 'http://localhost:8108' });

    const results = await client.collection('products').search({ q: 'keyboard', typoTolerance: false });
    ```
  </Tab>

  <Tab value="Python">
    ```python
    from tachyon_sdk import Tachyon

    client = Tachyon(url="http://localhost:8108")

    results = client.collection("products").search(q="keyboard", typo_tolerance=False)
    ```
  </Tab>

  <Tab value="C#">
    ```csharp
    using Tachyon.Sdk;

    var client = new TachyonClient(new TachyonClientOptions { Url = "http://localhost:8108" });

    var results = await client.Collection("products").SearchAsync(new SearchParams { Q = "keyboard", TypoTolerance = false });
    ```
  </Tab>
</Tabs>

If omitted, the collection's `typo_tolerance.enabled` setting is used.
