## Data Access Path

Recommended reading order, not a record of completed steps. Optional steps can be skipped.

1. [Get & Use an API Key](/en/docs/authentication)
2. [Make Your First Query](/en/docs/quickstart)
3. [Keyword & Semantic Search](/en/docs/search) ← current page
4. [Users, Topics, Tags & Categories](/en/docs/browse) (optional)
5. [Read Content & History](/en/docs/documents)
6. [Download Images & Attachments](/en/docs/attachments) (optional)
7. [Limits, Retries & Troubleshooting](/en/docs/production)

**Before You Start**：Complete your first query and decide between keyword/semantic matching and exact author or label filters.

# Keyword & Semantic Search

Complete reference for the `POST /v1/search` family. All endpoints require:


```http
Authorization: Bearer whale_consumer_xxx
Content-Type: application/json
```


Production base URL: `https://www.marsyoo.com`.

## Which endpoint

| Endpoint | Purpose |
| --- | --- |
| `POST /v1/search` | Default: historical index, optional live top-up |
| `POST /v1/search/history` | Historical index only, never triggers collection |
| `POST /v1/live-queries` | Create an on-demand collection task, see [Live Queries](/en/docs/live-query) |
| `POST /v1/contents/search` | Legacy alias of `/v1/search`; not recommended for new integrations |
| `POST /v1/search/keyword`, `/vector`, `/hybrid` | External dedicated search endpoints; prefer the unified endpoint's `mode` for most integrations |

For exact author/topic/tag/category filters, use [Users, Topics, Tags & Categories](/en/docs/browse). These catalog conditions cannot currently be combined with vector/hybrid search.

## Request fields

`POST /v1/search` and `POST /v1/search/history` share the same body. The only difference is that `/v1/search` accepts the `live` option.

| Field | Type | Required | Default | Notes |
| --- | --- | --- | --- | --- |
| `mode` | string | no | see notes | `keyword` / `vector` / `hybrid`. If omitted: `hybrid` when `query_vector` is set, otherwise `keyword` |
| `query` | string | conditional | — | Query text for keyword/hybrid; vector mode may use `query_vector` alone |
| `query_vector` | number[] | no | — | Supply your own embedding |
| `platforms` | string[] | no | full subscription | Platform filter; see [Platforms](/en/docs/platforms) |
| `languages` | string[] | no | all | ISO 639-1, e.g. `["zh","en"]` |
| `published_from` / `published_to` | string(RFC3339) | no | last 30 days | Platform publish-time window. With neither given, keyword and hybrid search cover content published in the last 30 days; pass a range to search older content |
| `limit` | int | no | 20 | Page size, max 100 |
| `cursor` | string | no | — | Keyword mode only; from the previous response |
| `fields` | string[] | no | authorized set | Response field allowlist; can only narrow, never expand |
| `include_highlights` | bool | no | false | Return highlight snippets |
| `include_chunks` | bool | no | false | Return matched chunk details in `matched_chunks` |
| `include_non_current` | bool | no | false | Include non-current versions |
| `sentiments` | string[] | no | all | Filter by sentiment: `positive` / `negative` / `neutral`; see [Filtering on analysis](#filtering-on-analysis) |
| `emotions` | string[] | no | all | Filter by emotion; any one matches |
| `entities` | string[] | no | all | Filter by entities, e.g. `["brand:Xiaomi", "Hangzhou"]`; all must be mentioned, up to 10 |
| `quality_statuses` | string[] | no | all | Filter by content quality, e.g. `["normal"]` |
| `intents` | string[] | no | all | Filter by intent, e.g. `["complaint", "churn"]`; any one matches |
| `live` | object | no | — | `/v1/search` only; see below |

### live options

| Field | Type | Required | Default | Notes |
| --- | --- | --- | --- | --- |
| `live.enabled` | bool | yes | — | Enable live top-up |
| `live.resource_kind` | string | yes | — | `content` / `account` / `user` / `channel` / `video` |
| `live.max_items_per_platform` | int | no | 20 | Per-platform cap, bounded by subscription quota |
| `live.deadline_seconds` | int | no | 300 | Collection deadline, 10–900 |

When `live.enabled` is true the request must carry an `Idempotency-Key` header, and needs 1–5 platforms.

## Response fields


```json
{
  "mode": "hybrid",
  "results": [
    {
      "document_id": "doc_01J...",
      "version_id": "ver_01J...",
      "best_chunk_id": "chunk_01J...",
      "dataset_id": "social_media_raw",
      "source_platform": "weibo",
      "title": "...",
      "body": "Best-matching chunk summary (not the full body)",
      "content_type": "post",
      "language": "zh",
      "published_at": "2026-09-01T08:00:00Z",
      "origin": "indexed",
      "score": 0.83,
      "keyword_score": 0.91,
      "vector_score": 0.74,
      "rerank_score": 0.83,
      "highlights": ["...<em>...</em>..."],
      "matched_chunks": [
        {"chunk_id": "chunk_01J...", "chunk_index": 3, "body": "...", "score": 0.91}
      ]
    }
  ],
  "total": 1,
  "total_documents": 1,
  "total_chunks": 1432,
  "top_k": 20,
  "degraded": false,
  "warnings": [],
  "live_query": null
}
```


| Field | Notes |
| --- | --- |
| `results[].document_id` | Document ID; use it to fetch details |
| `results[].body` | Best-chunk summary; full body via [Read Content & History](/en/docs/documents) |
| `results[].origin` | `indexed` (historical) / `live` (collected on demand) |
| `results[].score` | Final ranking score; rerank output for hybrid |
| `total` / `total_documents` | Deduplicated document count on this page, not a global document total |
| `total_chunks` | Backend chunk-hit count; vector/hybrid may report only candidate counts, not an exact global total |
| `cursor` | Present when more pages exist; pass it back verbatim as `cursor` |
| `degraded` | true when a backend was unavailable and results were downgraded |
| `warnings[]` | Downgrade/partial-failure reasons; see Errors and degradation |
| `live_query` | Live top-up handle with `id`, `status`, `runs[]` |

A `document_id` appears at most once per page.

## Filtering on analysis

Searches can add sentiment, emotion, entity, intent and content quality filters, in all three modes, or filter without a `query` (keyword mode).


```json
{
  "query": "battery",
  "platforms": ["xianyu"],
  "sentiments": ["negative"],
  "entities": ["brand:Xiaomi"]
}
```


- `sentiments`: a sentiment score over 0.3 is `positive`, under -0.3 `negative`, otherwise `neutral`; judgments under 0.4 confidence belong to none.
- `emotions`: `anger`, `disgust`, `fear`, `joy`, `sadness`, `surprise`, `neutral`; any one matches.
- `entities`: `type:name` (types in [Read Named Entities](/docs/documents#read-named-entities)) or a bare name of any type, normalized like stored entities (case, width, `@#`, quotes). Every listed entity must be mentioned.
- `quality_statuses`: content quality statuses: `normal`, `low`, `spam`, `duplicate`, `empty`.
- `intents`: values in [Read Intents](/docs/documents#read-intents); any one matches.
- Sentiment and emotion filters need the `affect` field in the application grant, entity filters the `entities` field, intent filters the `intents` field; otherwise `403`.
- Only analyzed content can match: content enters search with the analysis results it has by then, usually seconds to minutes after ingest. Content whose analysis is not done within 3 minutes still becomes searchable but does not match these filters. Entity re-checks are added later. Older history is not covered yet.
- Vector mode and the vector part of hybrid take about three times the candidates and then filter, so results can be fewer than `limit`; vector mode with analysis filters does not page with `cursor`.

## Pagination

`limit` defaults to 20, max 100. Only keyword mode supports cursor pagination. Vector/hybrid return Top-K candidates and do not enumerate all data; supplying `cursor` returns `400 invalid_query`. Keep keyword filters unchanged when passing back a returned cursor. No fixed cursor lifetime is promised. For complete synchronization, use catalog time windows or Change Feed, not semantic search as an export API.

`include_non_current=true` permits historical versions to participate, but results are still deduplicated by document ID per page. See [Read Content Version History](/en/docs/documents#read-content-version-history) for a document's version history.

## Live top-up

With `live.enabled=true` the response returns `origin=indexed` historical results plus:


```json
"live_query": {
  "id": "lq_01J...",
  "status": "pending",
  "resource_kind": "video",
  "runs": [
    {"id": "lqr_01J...", "platform": "youtube", "status": "pending", "collection_task_id": "ctask_01J..."}
  ]
}
```


Poll `GET /v1/live-queries/{id}` for status and `GET /v1/live-queries/{id}/results` for collected documents, see [Live Queries](/en/docs/live-query). If the live pipeline is unavailable the response still contains historical results with an explanatory `warnings[]` entry.

## Choosing a mode

| mode | Use for | Behavior |
| --- | --- | --- |
| `keyword` | Terms, brands, names, topic words in text | Title/body search, not exact topics/tags membership |
| `vector` | Semantic similarity, cross-language, paraphrases | Can use `query` alone; the server generates the embedding |
| `hybrid` | Default | Fuses lexical, vector, quality and recency signals; the vector branch waits at most 5s, then degrades to keyword results with `degraded=true` and `warnings[].code=vector_search_unavailable` |

## Authorization and quota

- `platforms` / `fields` can only narrow the subscription scope; out-of-scope requests return `403 entitlement_denied` or are trimmed.
- Daily quota is counted per UTC day, per application, per operation, and reserved atomically before hitting the search backend; requests rejected with `429` are not counted.
- Live concurrency/RPS is controlled by the subscription policy; violations return `429 rate_limit_exceeded` with `Retry-After`.

## Errors and degradation

| HTTP | code | Meaning | Action |
| --- | --- | --- | --- |
| 400 | `invalid_query` | Malformed params or unknown mode | Fix per this reference |
| 401 | `unauthorized` | Missing/invalid key | Check the Authorization header |
| 403 | `entitlement_denied` | Outside subscribed platforms or fields | Narrow scope or request access |
| 429 | `quota_exceeded` | Daily quota exhausted | Wait for the UTC reset or request a raise |
| 429 | `rate_limit_exceeded` | Live rate limit | Retry per `Retry-After` |
| 409 | `live_query_results_not_ready` | Live results not ready | Keep polling status |
| 503 | `search_backend_unavailable` | Search backend down | Exponential backoff |
| 503 | `vector_search_disabled` | Vector retrieval not open yet (`/v1/search/vector`, creating analysis runs) | Do not retry; use `keyword` or `hybrid` until it is announced as open |

Degradation (HTTP still 200, `degraded=true`):

| warnings[].code | Meaning |
| --- | --- |
| `vector_search_unavailable` | Vector branch timed out/unavailable; keyword results only |
| `vector_search_disabled` | Vector retrieval not open yet; keyword retrieval only |
| `keyword_search_timed_out` | Keyword branch timed out; results empty for this mode, retry with narrower scope |
| `keyword_search_partial` | Keyword search timed out before covering all data; results are incomplete and may miss recent content. Narrow the platforms, time range or query and retry |
| `live_query_unavailable` | Live top-up creation failed; historical results only |

## Check and Continue

**Completion Check**：Choose a search mode, apply platform/time filters, and understand snippets and pagination limits; use the next page for exact filters.

Previous step：[Make Your First Query](/en/docs/quickstart)

**Recommended Next Step**：[Users, Topics, Tags & Categories](/en/docs/browse) (optional; skip if not needed)

Skip optional steps：[Read Content & History](/en/docs/documents)