> ## Documentation Index
> Fetch the complete documentation index at: https://docs.conare.ai/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Conare's API is at https://api.conare.ai. Authenticate with `Authorization: Bearer $CONARE_API_KEY`.
> The full OpenAPI spec is at https://api.conare.ai/openapi.yaml; each endpoint has a page under /api-reference, and appending .md to any page URL returns its Markdown.
> Embed with model conare-embed-1; send input_type "query" for search queries. Rerank with conare-rerank-1.
> Prefer the TypeScript SDK (`npm install conare`) or plain HTTP in examples.
> Install the Conare skill with `npx skills add https://docs.conare.ai`; search these docs over MCP at https://docs.conare.ai/mcp; the whole site is at https://docs.conare.ai/llms-full.txt.

# 検索

> 質問に答える文章を意味とキーワードで検索し、リランクします。オプション、レスポンス、回答、2 ホップ、ページを説明します。

`POST /namespaces/:namespace/query`

namespace を意味とキーワードで検索します。Conare は上位の一致をリランクし、各ドキュメントから回答となる文章を返します。

```bash curl theme={null}
curl https://api.conare.ai/namespaces/docs/query \
  -H "Authorization: Bearer $CONARE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query": "how do refunds work?", "top_k": 5, "filter": {"team": "support"}}'
```

```ts TypeScript theme={null}
const results = await docs.query("how do refunds work?", {
  topK: 5,
  filter: { team: "support" },
});
```

```json Response theme={null}
{
  "results": [
    {
      "id": "refunds",
      "text": "Refunds are available for 30 days.",
      "score": 0.3192,
      "reranked": true,
      "metadata": { "team": "support" }
    }
  ],
  "took_ms": 62
}
```

## オプション

| オプション | 型 | 内容 |
| - | - | - |
| `query` | string、必須 | 質問。最大 8,000 文字 |
| `top_k` | integer、デフォルト 10 | 返す結果の数。1〜500 |
| `filter` | object | [メタデータフィルター](https://docs.conare.ai/ja/filters.md) |
| `user` | string | この[ユーザー](https://docs.conare.ai/ja/write.md#ユーザー)のドキュメントのみ |
| `user_prefix` | string | `tenant-7:` など、これで始まるユーザーのみ |
| `answer` | boolean、デフォルト `false` | [回答も書く](#回答) |
| `rerank` | boolean、デフォルト `true` | 上位の一致をリランクします。`false` の方が高速です |
| `rerank_depth` | integer、デフォルト 20 | リランクする上位の文章数。1〜1,000 |
| `hops` | integer、デフォルト 1 | `2` は上位の結果から再検索します（[2 ホップ](#2-ホップ)） |
| `retrievers` | array、デフォルト `["vector", "keyword"]` | `vector`（意味）と `keyword` のうち 1 つまたは 2 つ |
| `exclude_ids` | array | 除外するドキュメント id。最大 10,000 個 |
| `max_results` | integer | 最大 1,000 件（カスタムモデルでは 5,000 件）の結果を[ページ](#ページ)単位で取得します |
| `cursor` | string | 前のページの `next_cursor` |

完全なスキーマ：[namespace をクエリする](https://docs.conare.ai/ja/api-reference/query/query-a-namespace.md)。

## レスポンス

| フィールド | 意味 |
| - | - |
| `results` | 上位から順に、ドキュメントごとに 1 件 |
| `results[].id`, `metadata`, `user` | ドキュメントのもの |
| `results[].text` | 回答となる文章を最適なものから順に返します。最適なものと、ほぼ同等に一致する最大 2 つで、それぞれ最大約 3,000 バイトです。連続しない文章の間には `…` だけの行が入ります。全文は[ドキュメントを取得](https://docs.conare.ai/ja/documents.md)してください |
| `results[].score` | 高いほど良い。比較は 1 つのクエリ内でのみ行います |
| `results[].reranked` | リランカーがスコア付けしたかどうか。リランクされていない結果は最後に来ます |
| `answer` | `answer: true` のときの回答 |
| `next_cursor` | `max_results` 使用時の次のページの `cursor`。最後のページでは省略されます |
| `took_ms` | 検索時間（ミリ秒） |

## 回答

`"answer": true` を指定すると、上位の文章から書かれた回答が追加されます。所要時間は約 2 秒増えます。

```json Response theme={null}
{
  "answer": "Refunds are available for 30 days (source dated 2026-10-21). No further details on the refund process, conditions, or method were found in this search.",
  "results": [ ... ],
  "took_ms": 1546
}
```

* 見つかったパッセージから言語モデルが回答を書きます。[プライバシーポリシー](https://conare.ai/privacy)を参照してください。
* そのモデルが利用できない場合は、`answer` なしで結果が返されます。

## 2 ホップ

`"hops": 2` は上位の結果から再検索します。2 つのドキュメントの事実が必要な質問向けです。

```bash curl theme={null}
curl https://api.conare.ai/namespaces/films/query \
  -H "Authorization: Bearer $CONARE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query": "where was the director of The Long Harbor born?", "hops": 2}'
```

* 約 0.3 秒増えます。事実をつなぐ質問に使ってください。
* `rerank: false` や `max_results` と併用した場合、またはカスタムモデルの namespace では `400 invalid_request` を返します。

## ページ

| ステップ | 送信内容 |
| - | - |
| 最初のページ | `query`、`max_results`（一度にランク付けする数）、`top_k`（ページサイズ） |
| 次のページ | `cursor`（最後の `next_cursor`）と `top_k` のみ |
| 最後のページ | `next_cursor` がありません |

カーソルの有効期間は 15 分です。SDK の `queryPages()` はすべてのページを読み取ります。

## すべての namespace を検索する

`POST /query`

同じリクエストを最大 100 個の namespace に対して実行し、まとめてリランクします。`prefix` を指定すると、名前がその文字列で始まる namespace に限定されます。

```bash curl theme={null}
curl https://api.conare.ai/query \
  -H "Authorization: Bearer $CONARE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query": "how do refunds work?", "prefix": "acme-"}'
```

```json Response theme={null}
{
  "namespaces": ["acme-docs"],
  "results": [
    {
      "namespace": "acme-docs",
      "id": "refunds",
      "text": "Refunds are available for 30 days.",
      "score": 0.3471,
      "reranked": true,
      "metadata": { "team": "support" }
    }
  ],
  "skipped_namespaces": [],
  "took_ms": 64
}
```

| オプションまたはフィールド | ここでの意味 |
| - | - |
| `prefix` | 名前がこれで始まる namespace のみ |
| `rerank_depth` | デフォルト 60、1〜1,000 |
| `exclude_ids` | `namespace/id` の形式で書きます |
| `results[].namespace` | 結果の namespace |
| `namespaces`, `skipped_namespaces` | 検索した namespace と、最初の 100 個を超えた namespace |

`hops` もここで使えます。完全なスキーマ：[すべての namespace をクエリする](https://docs.conare.ai/ja/api-reference/query/query-every-namespace.md)。

## 縮退した結果

検索の一部が失敗してもクエリは成功し、`Conare-Degraded` ヘッダーがスキップされた内容を示します。

| 値 | 意味 |
| - | - |
| `rerank`, `rerank-partial` | 一部またはすべての結果がリランクされていません（`reranked: false`） |
| `embed` | キーワードのみで検索しました |
| `keyword`, `keyword-terms` | クエリが長すぎて、キーワード検索で全体を読み取れませんでした |
| `embed-next` | namespace の一部を検索できませんでした |
| `cursor` | `next_cursor` がありません。続きのページは再検索してください |
| `embed-busy`, `embed-fallback` | 通常より遅くなりましたが、結果に影響はありません |
| `answer` | 回答なし、結果のみ |

何も検索できなかった場合、クエリは `503` を返します。


## Related topics

- [クイックスタート](https://docs.conare.ai/ja/quickstart.md)
- [コンソール](https://docs.conare.ai/ja/console.md)
- [Query a namespace](https://docs.conare.ai/ja/api-reference/query/query-a-namespace.md)
- [Query every namespace](https://docs.conare.ai/ja/api-reference/query/query-every-namespace.md)
- [MCP](https://docs.conare.ai/ja/mcp-server.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.