Searches an index, forgiving typos.
Searches an index, forgiving typos. Ranks the org's documents in one index against `q` and answers the matching documents whole, most relevant first.
POST /v1/index/indexes/{uid}/search
| 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 | — | Limit is how many hits to return. |
offset | body | integer | — | Offset is where to start. |
q | body | string | — | Q is the search text. |
Response
| Status | Body | Meaning |
|---|---|---|
200 | indexHits | ok |
200 body — 6 fields.
| Field | In | Type | Always | Description |
|---|---|---|---|---|
estimatedTotalHits | body | integer | — | 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 | — | Limit is how many hits this page could hold. |
offset | body | integer | — | Offset is where this page starts. |
processingTimeMs | body | integer | — | 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.
Examples
hanzo index indexes search <uid>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 });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)cfg := cloud.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := cloud.NewAPIClient(cfg)
resp, _, err := client.IndexAPI.PostIndexIndexesByUidSearch(context.Background()).Execute()
if err != nil {
return err
}use hanzo_cloud::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?;import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.IndexApi;
ApiClient client = new ApiClient();
client.setRequestInterceptor(b -> b.header("Authorization", "Bearer " + System.getenv("HANZO_API_KEY")));
var result = new IndexApi(client).postIndexIndexesByUidSearch();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
}'The door reaches index through the index tool, which names its 17 operations with its own verbs — this one among them, under a name only the door declares. describe explains any of them:
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"
}
}
}'How is this guide?