# Search
URL: /api/search

Query a collection, and get autocomplete suggestions.



## Search [#search]

<Callout type="info">
  Requires the admin or search key.
</Callout>

```
GET /collections/{name}/search
```

**Query parameters**

| Parameter        | Type               | Default            | Description                                                   |
| ---------------- | ------------------ | ------------------ | ------------------------------------------------------------- |
| `q`              | string             | —                  | The search query                                              |
| `query_by`       | string             | all text fields    | Comma-separated text fields to search                         |
| `filter`         | string             | —                  | Filter expression — see [Filtering](/docs/filtering)          |
| `sort`           | string             | relevance          | Sort expression — see [Sorting](/docs/sorting)                |
| `facet`          | string             | —                  | Comma-separated facet fields — see [Faceting](/docs/faceting) |
| `limit`          | int                | `10`               | Results per page, max `250`                                   |
| `offset`         | int                | `0`                | Results to skip; `offset + limit` capped at `10,000`          |
| `prefix`         | bool               | `true`             | Treat the last token as a prefix match                        |
| `typo_tolerance` | bool               | collection setting | Override typo tolerance for this query                        |
| `match_mode`     | `"all"` \| `"any"` | `"all"`            | Whether every `query_by` term must match                      |

<Tabs items="['cURL', 'TypeScript', 'Python', 'C#']">
  <Tab value="cURL">
    ```bash
    curl 'localhost:8108/collections/products/search?q=wireless+mouse&filter=price:<5000&sort=_text_match:desc' \
      -H 'x-tachyon-api-key: your-search-key'
    ```
  </Tab>

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

    const client = new Tachyon({ url: 'http://localhost:8108', apiKey: 'your-search-key' });

    const results = await client.collection('products').search({
      q: 'wireless mouse',
      filter: 'price:<5000',
      sort: '_text_match:desc',
    });
    ```
  </Tab>

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

    client = Tachyon(url="http://localhost:8108", api_key="your-search-key")

    results = client.collection("products").search(
        q="wireless mouse",
        filter="price:<5000",
        sort="_text_match:desc",
    )
    ```
  </Tab>

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

    var client = new TachyonClient(new TachyonClientOptions { Url = "http://localhost:8108", ApiKey = "your-search-key" });

    var results = await client.Collection("products").SearchAsync(new SearchParams
    {
        Q = "wireless mouse",
        Filter = "price:<5000",
        Sort = "_text_match:desc",
    });
    ```
  </Tab>
</Tabs>

**Response** — a `SearchResponse`:

```json
{
  "found": 1,
  "found_is_exact": true,
  "search_time_ms": 0,
  "hits": [
    { "document": { "id": "1", "title": "Wireless Mouse", "price": 2999 }, "text_match": 554.788 }
  ],
  "facets": null
}
```

| Field               | Description                                                 |
| ------------------- | ----------------------------------------------------------- |
| `found`             | Total matching documents                                    |
| `found_is_exact`    | Whether `found` is an exact count                           |
| `search_time_ms`    | Server-side query time                                      |
| `hits[].document`   | The full indexed document                                   |
| `hits[].text_match` | BM25 relevance score                                        |
| `facets`            | Per-field value → count, present only if `facet` was passed |

There is no highlighting field in the response — see
[Searching → Highlighting](/docs/searching#highlighting).

## Autocomplete [#autocomplete]

<Callout type="info">
  Requires the admin or search key.
</Callout>

```
GET /collections/{name}/suggest
```

Completes the last token of `q`, prefix- and typo-tolerant.

| Parameter        | Type   | Default            | Description                                     |
| ---------------- | ------ | ------------------ | ----------------------------------------------- |
| `q`              | string | —                  | Partial query to complete                       |
| `query_by`       | string | all text fields    | Comma-separated fields to draw suggestions from |
| `limit`          | int    | `5`                | Max suggestions, max `50`                       |
| `typo_tolerance` | bool   | collection setting | Override typo tolerance                         |

```bash
curl 'localhost:8108/collections/products/suggest?q=key&query_by=title'
```

```json
{
  "suggestions": [
    { "text": "keyboard", "count": 128, "typos": 0 }
  ],
  "search_time_ms": 0
}
```

`count` is the term's document frequency. Exact prefix matches are ranked
before typo-corrected ones, then by `count` descending, then alphabetically.
