# Search indexes

URL: https://docs.hanzo.ai/docs/openapi/index/post-index-indexes-by-uid-search

> Searches an index, forgiving typos.

`POST /v1/index/indexes/{uid}/search`

> [Index →](https://docs.hanzo.ai/docs/openapi/index) · [All API references →](https://docs.hanzo.ai/docs/openapi) · [Get started →](https://docs.hanzo.ai/docs/guides)

|               |                                                      |
| ------------- | ---------------------------------------------------- |
| **Address**   | `https://api.hanzo.ai/v1/index/indexes/{uid}/search` |
| **Method**    | `POST`                                               |
| **Operation** | `post_index_indexes_by_uid_search`                   |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY`               |

Searches an index, forgiving typos.

Ranks the org's documents in one index against `q` and answers the matching
documents whole, most relevant first. A prefix matches, so a partial word
finds the documents containing it, and `filter` narrows the result to
documents whose filterable attributes match — which is how a caller scopes
results to one end user within its own org.

`estimatedTotalHits` is the dialect's name for the count; every hit is
materialised here, so for this page it is exact. An index this org does not
hold answers 404 carrying the dialect's `index_not_found`.

## Request

5 fields, body `application/json` (required).

| Field    | In   | Type            | Required | Description                                                                                                  |
| -------- | ---- | --------------- | -------- | ------------------------------------------------------------------------------------------------------------ |
| `uid`    | path | string          | yes      |                                                                                                              |
| `filter` | body | any             | —        | Filter narrows the hits, in the dialect's filter syntax: a string, or an array of strings combined with AND. |
| `limit`  | body | integer (int64) | —        | Limit is how many hits to return.                                                                            |
| `offset` | body | integer (int64) | —        | Offset is where to start.                                                                                    |
| `q`      | body | string          | —        | Q is the search text.                                                                                        |

## Response

| Status    | Body            | Meaning |
| --------- | --------------- | ------- |
| `200`     | index.indexHits | ok      |
| `default` | problem-details | refused |

`200` body — 6 fields.

| Field                | In   | Type            | Always | Description                                                                      |
| -------------------- | ---- | --------------- | ------ | -------------------------------------------------------------------------------- |
| `estimatedTotalHits` | body | integer (int64) | —      | EstimatedTotalHits is the dialect's name for the match count.                    |
| `hits`               | body | any\[]          | —      | Hits are the matching documents, most relevant first, exactly as stored.         |
| `limit`              | body | integer (int64) | —      | Limit is how many hits this page could hold.                                     |
| `offset`             | body | integer (int64) | —      | Offset is where this page starts.                                                |
| `processingTimeMs`   | body | integer (int64) | —      | ProcessingTimeMs is how long the query took, in milliseconds.                    |
| `query`              | body | string          | —      | Query echoes the search terms, which is what a client renders above the results. |

Failure carries the platform error shape — see [Errors](https://docs.hanzo.ai/docs/errors).

## Examples

**CLI**

```bash
hanzo index indexes search <uid>
```

**SDK**

**.ts**

```ts
import { Configuration, IndexApi } from 'hanzoai';

const api = new IndexApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postIndexIndexesByUidSearch({ uid: 'uid', filter: "<filter>", limit: 0 });
```

**.py**

```python
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import IndexApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = IndexApi(client).post_index_indexes_by_uid_search(uid='uid', filter="<filter>", limit=0)
```

**.go**

```go
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.IndexAPI.PostIndexIndexesByUidSearch(context.Background()).Execute()
if err != nil {
	return err
}
```

**.rs**

```rust
use hanzo_client::apis::{configuration::Configuration, index_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = index_api::post_index_indexes_by_uid_search(&cfg, Default::default()).await?;
```

**.java**

```java
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.IndexApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new IndexApi(client).postIndexIndexesByUidSearch();
```

**HTTP**

```bash
curl -X POST https://api.hanzo.ai/v1/index/indexes/<uid>/search \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "filter": "<filter>",
       "limit": 0
     }'
```

**MCP**

MCP reaches **index** through the `index` tool, which names its 14 operations with its own verbs — this one among them, under a name only MCP declares. `describe` explains any of them:

```bash
curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "describe",
         "arguments": {
           "op": "get_index_health"
         }
       }
     }'
```

---

[Index API](https://docs.hanzo.ai/docs/openapi/index) · [All Hanzo APIs](https://docs.hanzo.ai/docs/openapi) · [Interactive reference](https://docs.hanzo.ai/docs/openapi/reference)
