> ## Documentation index
> Fetch the complete documentation index at: https://docs.predictefy.com/llms.txt
> Use it to discover every available page before exploring further.

# Search

> Choose lexical, semantic, or hybrid market search and understand filtering, ranking, and index freshness.

Search markets with `GET /api/{exchange}/fetchMarkets` and a `query`.
Use `router` for all served venues, or a venue id to search one venue.

A query also matches venue market ids and tickers, and event names.

## Choose a search mode

| `searchMode` | What it does                                                                                                                               |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `lexical`    | The default. Matches query words against market questions and titles. English word normalization handles word forms and common stop words. |
| `semantic`   | Ranks embedded markets by meaning rather than requiring the query words in their titles.                                                   |
| `hybrid`     | Combines lexical matches with semantic similarity, merges their rankings, and returns each market once per page.                           |

Hybrid ranking rewards a higher position in either list and adds those contributions
when a market appears in both. Ties use market id order. The lexical list follows
`sort`, which defaults to volume; the semantic list follows similarity. Hybrid's final
order combines those positions rather than simply sorting every result by volume.

Semantic and hybrid modes require a non-empty `query`. They exclude Kalshi parlays.
If semantic search is disabled, they return `NOT_SUPPORTED`. Some search-storage
failures fall back to lexical results; a failed query embedding returns
`CATALOG_UNAVAILABLE`.

When vector statements time out or vector support is unavailable, lexical results include `meta.searchFallback`.
It contains `requestedMode` (`semantic` or `hybrid`), `servedMode` (`lexical`), and `reason` (`timeout` or `index_unavailable`).
Cursor continuation pages retain this marker and its reason. Successful searches omit it.

## Reviewed synonyms

Lexical search uses directional, whole-query aliases from a reviewed, versioned synonym table.
Matching ignores case, trims surrounding whitespace, and collapses repeated whitespace.

`super bowl` also searches `pro football`; the reverse query has no alias.
There is no substring rewriting: `super bowl winner` stays unchanged.
Expansion keeps the original query first and includes at most four distinct branches.
Filters apply to every branch.
Lexical results are deduplicated in catalog order.

This expansion also covers hybrid's lexical candidates and lexical fallback.
Semantic search and hybrid's semantic branch embed the original text.
The table changes only through a reviewed release.

For nonempty queries, market, event, and series search cursors bind the synonym revision.
Older search cursors return `400 VALIDATION_ERROR`, so a search walk must restart from the first page.

## Filters and page size

| Filter                           | Behavior                                                                                                                                                          |
| -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `{exchange}`                     | `router` searches all served venues; `polymarket` or `kalshi` restricts the search to that venue.                                                                 |
| `status`                         | Defaults to `active`. Accepts `active`, `open`, `inactive`, `closed`, `resolved`, or `all`. `open` aliases `active`.                                              |
| `closeAfter`, `closeBefore`      | Exclusive bounds on the stored `resolutionDate`. Markets without a stored close date are excluded unless `undated=include`.                                       |
| `undated`                        | `exclude` (default) drops markets without a stored close date under a close bound; `include` keeps them; `only` returns undated markets and rejects close bounds. |
| `ids`                            | One comma-separated list of up to 80 venue-prefixed market ids. Results keep the requested order and `meta.count` reports the returned match count.               |
| `updatedAfter`, `sort=updatedAt` | `updatedAfter` is an exclusive lower bound on the row write time; `sort=updatedAt` walks it ascending and requires lexical search.                                |
| `searchIn`                       | `title` by default; `description` and `both` change the lexical portion. Semantic similarity still uses stored embeddings.                                        |

Close-date bounds use stored venue close or expiry dates. Some are distant backstop
dates, so a market can settle earlier. Bounds accept epoch milliseconds, a date, or
a timestamp with a timezone. Date-only bounds mean UTC midnight.

The `category` family also accepts the synthetic
`uncategorised` slug, which matches markets with no canonical category, including null and
off-vocabulary values. It is filterable with `category`, `categories`, and `excludeCategories`.

A page defaults to **20 results** and accepts `limit` up to **500**. Twenty is a
default page size, not a cap on all matches. Follow `page.hasMore` and
`page.nextCursor`. Semantic totals describe matches within a bounded candidate
window; hybrid totals describe the merged candidates. Neither is a count of every
potentially relevant market.

Hybrid results are re-ranked for each page. A cursor walk can repeat or skip markets,
and `page.total` can change between pages. Prefer one page with `limit` up to **500**.
If you page, deduplicate by `marketId` within each venue; include `sourceExchange` when
using `router`. Deduplication removes repeats but cannot recover skipped markets.

Search similarity does not establish a cross-venue relationship or resolution
equivalence. Use [Cross-venue data](/guides/cross-venue/) and its recorded
`matchQuality` labels for that distinction.

## Close-date echoes

Every accepted `closeAfter` or `closeBefore` query parameter has
a matching `meta.closeAfter` or `meta.closeBefore` string.
Each field is present exactly when its matching query parameter was supplied and accepted.
It echoes the parsed bound used by the query, normalized to a UTC ISO instant with millisecond
precision. An unsupplied bound adds no echo.

The close-bound echoes sit in page `meta`
beside `meta.asOf` and `meta.provenance`.

For `closeAfter=2026-11-01&closeBefore=2026-12-01`, the response metadata includes:

```json
{
  "meta": {
    "closeAfter": "2026-11-01T00:00:00.000Z",
    "closeBefore": "2026-12-01T00:00:00.000Z"
  }
}
```

The rule covers `fetchMarkets`, `fetchEvents`, and their Paginated aliases on router and venue
routes, through both the hot catalog and the stored catalog. First, continuation, and empty
pages all echo accepted bounds. Equal bounds give an empty page with both echoes. Event bounds
filter member markets before grouping, so events contain only matching members. Repeat the
original bounds on continuation requests.

A page carrying an echo for a bound the request did not send is refused with non-retryable
`CLOSE_BOUNDS_IGNORED`, naming `meta.closeAfter` or `meta.closeBefore`.

Older servers omit these fields. The TypeScript and Python SDKs refuse bounded pages with
missing, non-string, or mismatched canonical echoes using `CLOSE_BOUNDS_IGNORED`. MCP and the
CLI inherit this refusal. Matching rows alone cannot prove filtering. Unbounded requests
remain compatible with older servers. See the [SDK guide](/guides/sdk/#close-date-bounds-and-echoes)
for error details.

## How fresh is search?

New markets first enter the catalog, which refreshes every **2 hours**. The title-search
snapshot refreshes every **15 minutes**. Each refresh incrementally
reloads rows whose write time advanced since the previous one, with a short overlap. A full rebuild
runs every **6 hours by default**, which the service may tune.

New or renamed markets enter snapshot-backed lexical results after the catalog refresh
and the next completed refresh that includes them. They normally appear within about
**15 minutes** of the catalog refresh plus processing time, with no fixed maximum.
A missed row waits for the next full rebuild unless a later update makes it
eligible for another incremental reload.

That cadence describes the title-search snapshot. Hybrid search and lexical queries
that cannot use that snapshot read the stored catalog directly, so their lexical
matches can reflect catalog changes sooner.

Semantic search has a separate clock. Stored embeddings are updated during cross-venue matching
runs, which can take hours. A market can therefore appear lexically before it
appears semantically. The [market-screening guide](/guides/cookbook/screen-markets/#sweep)
describes the embedding delay; the snapshot cadence does not shorten it.

## Worked examples

These are request paths. Add your normal API authentication.

**Find active markets mentioning bitcoin across venues.** Omitting `searchMode`
uses lexical search, with the default volume ordering.

```http
GET /api/router/fetchMarkets?query=bitcoin&status=active
```

**Search a concept on one venue.** This ranks Polymarket's embedded active markets
by meaning, so titles need not contain the exact phrase.

```http
GET /api/polymarket/fetchMarkets?query=interest%20rate%20cuts&searchMode=semantic&status=active
```

**Combine words and meaning inside a close-date window.** This searches active
Kalshi markets whose stored close dates fall strictly between the example dates.

```http
GET /api/kalshi/fetchMarkets?query=inflation&searchMode=hybrid&status=active&closeAfter=2026-11-01&closeBefore=2026-12-01
```

**Search descriptions as well as titles.** This asks for active markets whose
question/title text or description matches the words.

```http
GET /api/router/fetchMarkets?query=weather&searchIn=both&status=active
```

Market lists accept `sort=closeDate` (earliest first, unknown dates last). Use
`/api/router/fetchMarkets?venues=polymarket,kalshi` to restrict the union to served venues.
Venue filters remain bound to pagination cursors and exact filtered totals.

Market lists also accept inclusive `volume24hMin`, `liquidityMin`, `priceMin`, and
`priceMax` filters. Volume and liquidity use native venue units; prices use stored
`yes_price` between 0 and 1, before live overlays. Missing metrics do not match a bound.
Semantic and hybrid results are ranked by relevance: `sort` is not applied in those modes
(every sort token, including `rewardsDailyRate`), and `sortDir` is refused outright.
Filters apply before counting and pagination. `sortDir=asc|desc` controls lexical catalog
ordering. Defaults remain ascending for `closeDate` and descending for other sorts;
unknown values stay last and ties use ascending market IDs in either direction.
Event results with `sort=volume` rank by the summed native `volume24h` of their filtered members before pagination.
`venueVolume24h` serves stored venue-stated parent volume (Opinion includes closed children; Gemini publishes one total per event and no per-contract figure), or null when unavailable, without changing filtered member sums or ordering.
See [event volume order](/guides/events-series/#event-volume-order) for unknown values, ties and cursor restarts.
Explicit direction with semantic/hybrid search returns `400 NOT_SUPPORTED` because
those searches use relevance ranking. `priceChange24hMin` remains `400 NOT_SUPPORTED`
until snapshot-consistent enrichment support exists.
