# Search

Search the web with attributed results and automatic fallback across sources.

`search` returns ranked results with their URL, title and snippet. Every result
says which source found it, and every result is checked: inside the date window
you asked for, about what you asked for, and an actual item rather than a
homepage, listing or challenge page.

- Free by default: your own [SearXNG](/docs/integrations/searxng/) (optional,
  no Docker: `frankensurf install search`, and search is stronger with it), then
  [DuckDuckGo](/docs/integrations/duckduckgo/) and [Bing](/docs/integrations/bing/),
  plus [Google News](/docs/integrations/google-news/), Wikipedia, Hacker News,
  Stack Exchange, GitHub, arXiv, Open Library, and `site_watch`, which reads a
  site's own feeds and sitemaps.
- When a source's results fail the checks, Frankensurf climbs to the next one
  and merges what passed ([the search ladder](#the-search-ladder)).
- Paid sources [Exa](/docs/integrations/exa/), Firecrawl search,
  [Brave](/docs/integrations/brave/), [Tavily](/docs/integrations/tavily/),
  [Parallel](/docs/integrations/parallel/), [Serper](/docs/integrations/serper/),
  [SerpAPI](/docs/integrations/serpapi/) and
  [Google Programmable Search](/docs/integrations/google-cse/) join when their keys
  are set and you allow paid tools, cheapest likely success first.
- Name a source and Frankensurf uses only that one, never a substitute.

## Usage

```python
results = await web.search("playwright python tutorial", limit=10)
for hit in results["results"]:
    print(hit["title"], hit["url"])
```

```bash
frankensurf search playwright python tutorial --limit 10
```

```json
{ "tool": "search", "arguments": { "query": "playwright python tutorial", "limit": 10 } }
```

```json title="Response (trimmed)"
{
  "query": "playwright python tutorial",
  "source": "searxng",
  "coverage": "partial",
  "results": [
    {
      "url": "https://www.browserstack.com/guide/playwright-python-tutorial",
      "title": "The ultimate Playwright Python tutorial | BrowserStack",
      "snippet": "Learn end-to-end web testing with Playwright Python…",
      "engines": ["duckduckgo"],
      "verification": "indexed_discovery"
    },
    {
      "url": "https://playwright.dev/python/docs/library",
      "title": "Getting started - Library | Playwright Python",
      "snippet": "These commands download the Playwright package and install browser binaries…",
      "engines": ["duckduckgo"],
      "verification": "indexed_discovery"
    }
  ],
  "upstream_failures": [["brave", "too many requests"], ["google cse", "too many requests"]]
}
```

`coverage: "partial"` and `upstream_failures` show that some of SearXNG's own
engines were rate-limited. Failures stay visible instead of looking like "no
results".

## Narrow it down

```python
results = await web.search("film camera repair", recency="week", region="en-AU",
                           exclude_domains=["pinterest.com", "youtube.com"])
```

```bash
frankensurf search film camera repair --recency week --region en-AU \
  --exclude-domain pinterest.com --exclude-domain youtube.com
```

- `site`: only results from one domain (its subdomains too).
- `exclude_domains`: up to 200 domains that never come back. Subdomains match too (excluding `example.com` drops `news.example.com`). Engines get only the first few as `-site:` operators (`search_exclude_operators`, default 3); the full list is enforced on the results, and the search asks for extra results so the limit is still met.
- `recency`: `day`, `week`, `month` or `year`.
- `region`: language and country, like `en-AU` or `de`.

Each source applies what it can natively: SearXNG `time_range`, DuckDuckGo
`df` and `kl`, Bing's date filters and `cc`, Exa and Tavily domain and date
filters, Brave `freshness`, and `site:`/`-site:` operators where an engine
reads them. Then every result list is filtered again, so an excluded domain
never comes back from any source, and dated results older than the window are
dropped. `receipt.search_options.filtered` counts what went, including how
many results had no date to check.

## Boolean queries

Monitoring tools write queries like `"Rio Tinto" OR "Rio Tinto Group" (acquisition
OR layoffs OR "data breach")`. Each source gets the query as written. The checks
judge results by what the query names: a story that names Rio Tinto (or Rio Tinto
Group) is on the query without also naming an event word, which only narrows what
the engines return. Event words (acquisition, layoffs, lawsuit, funding, earnings ...)
beside a name make it a news search.

Free sources often mishandle long OR-lists, returning homepages or nothing. When a
boolean query's answer is not good, Frankensurf searches once more for the main name
alone (`"Rio Tinto"`), in the same vertical and window, and keeps whichever answer
passed more results. `receipt.query_simplified` says what was asked, what was kept and
what the first try cost:

```json
"query_simplified": {"from": "\"Rio Tinto\" OR ...", "to": "\"Rio Tinto\"", "kept": "simpler",
                     "why": "the query as written got a weak answer (2 results passed the checks)"}
```

A named source is never retried. On 12 companies with free sources only and no
SearXNG, a monitoring-style query found every company, against 7 of 12 before.

## Kinds of search

`vertical` picks the kind of source. Automatic fallback stays inside it. Leave
it out and FrankenSurf infers it from the query, so `fastify github repo` gets
the code treatment and `who wrote Hamlet` the reference one. An explicit
`vertical` always wins.

| `vertical` | Source | Notes |
| --- | --- | --- |
| `web` (the fallback) | SearXNG, DuckDuckGo, Bing, plus paid sources when allowed | |
| `news` | Bing News RSS | Publisher in `extra.publisher`, dates on every item |
| `reference` | Wikipedia API | In the `region` language (`de` searches de.wikipedia.org). Question words are dropped (`who wrote War and Peace` searches for *War and Peace*), the article titled for the topic comes first, disambiguation pages are dropped, and titles with a qualifier such as `(film)` or `(1956 film)` go last unless the query asks for that kind of thing |
| `discussions` | Hacker News (Algolia API) | `extra.points`, `extra.comments`, `extra.discussion_url` |
| `qa` | Stack Exchange API | Stack Overflow by default; any Stack Exchange site by name via `engine_config={"engines": "superuser"}` |
| `code` | GitHub API | Repositories; `recency` means pushed recently. `extra.stars`. Platform words (*github*, *repo*, *library*, *package*, *crate*, *source code*) and filler are not sent as search terms. A project name (`fastify github repo`) searches repository names; a need (`python library for image processing`) searches names and descriptions and turns a language word into a `language:` filter. Results are sorted by stars |
| `papers` | arXiv API | |
| `books` | Open Library | |

All of these are official, keyless public APIs.

### Inferred verticals

When no `vertical` is given, the query's wording picks one. The rules are
deterministic and use common words and sentence shape only, never lists of
sites or companies. A query that matches nothing is `web`. Rules are checked in
this order and the first match wins.

| Inferred | Signals | Example |
| --- | --- | --- |
| `qa` | An error or how-to (*how to*, *how do I*, *error*, *exception*, *fix*, *fails with*) together with code-shaped tokens (`snake_case`, `call()`, file extensions, error codes) or a language name | `how to reverse a list in python` |
| `papers` | *papers on*, *paper on*, *research on*, *arxiv*, *preprint*, *survey of* | `papers on retrieval augmented generation` |
| `code` | Platform words (*github*, *gitlab*, *repo*, *repository*, *crate*, *npm*, *pypi*, *source code*); *library for*, *framework for*, *sdk for*; a language beside *library*, *package*, *crate*, *module* or *framework* | `python library for image processing` |
| `web` | Announcement phrasing (*announces*, *announcement*, *press release*, *launch*) stays windowed web, not news | `Anthropic announces new model` |
| `news` | *news*, *headlines*, *latest on*; an entity with *today* or *this week* | `openai news` |
| `reference` | Fact questions: *who*, *what is*, *what year*, *when was*, *how tall*, *how many*, *capital of*, *population of*, *currency of*, *wrote*, *invented*, *founded*, *painted*, *composed*, *discovered*; not when the query asks for *best*, *vs*, *review* or buying advice | `who wrote Hamlet` |

A how-to with no code in it (`how to boil an egg`) stays `web`, as do words that
are only sometimes about software (`Python the snake`, `Go to market strategy`,
`package delivery tracking`). An explicit `source` is never re-routed. The
receipt says what was picked and why:
`receipt.search_routing.vertical_inferred` is `{"vertical": "code", "reason": "platform word: github"}`.
It is absent when you passed a `vertical` yourself. `mode="merge"` infers the same way.

A vertical with its own specialist source (`code`, `reference`, `papers`, `news`)
does not wait for it to fail. When the local SearXNG is reachable, the
specialist and SearXNG start together as the first rung, and their answers are
merged, checked and ranked as one. If one fails or is slow it is simply left
out (the slower one gets a few seconds after the first answer). Turning off
`search_hedge_after_seconds` turns this racing off too.

## Local search

Search works with nothing installed. A local SearXNG makes it stronger:
`frankensurf install search` installs and starts one, no Docker needed, and
search starts it again after a reboot. `frankensurf search-engine start`, `stop`
and `status` manage it. See [SearXNG](/docs/integrations/searxng/).

Expect it to thin out at volume. SearXNG asks the public engines from your own
address, and Google, Brave and DuckDuckGo start refusing (CAPTCHAs, blocks) after a
few dozen searches in a few minutes; in one test, 39 of the first 100 searches met a
refusal. Frankensurf's settings switch on more engines (Bing, Yahoo, Qwant, Mojeek
beside them) and rest a refusing engine for 15 minutes, so some keep answering, but
for steady volume (hundreds of searches an hour) add a paid source such as
[Serper](/docs/integrations/serper/) ($1 per 1,000) and allow paid tools.

When an automatic search ran without it because nothing answered on
`127.0.0.1:8088`, the receipt says why results may be thinner:

```json
"search_routing": {
  "local_search": {
    "status": "not_running",
    "note": "Local search (SearXNG) was not running, so this search used other sources and may be thinner. Start it with: frankensurf search-engine start",
    "start_with": "frankensurf search-engine start"
  }
}
```

The field is absent when SearXNG answered, when you named a source, and when
you pointed at your own search URL.

## The search ladder

An automatic search (no `source`) does not stop at the first source that answers.
It checks every result set the way a read checks a page, and climbs to the next
source until a set is good: at least `min(3, limit)` results (`search_good_results`)
that pass.

A result fails when it:

- is provably outside the `recency` window (its own date, a date the snippet
  leads with, "3 days ago", or a `/2026/10/12/` URL path; an unknown date is not a
  failure, it only ranks below dated in-window results);
- shares no key term with the query (stopwords and words like *news*, *latest*,
  *this week* don't count);
- is a homepage, search page, tag listing or challenge page, when the query asks
  for specific items (a path that ends in an index word such as `/newsroom/`,
  `/changelog/`, `/press-releases/` or `/c/announcements/22`, or an aggregator's
  `/news/<company>`, is a listing; a path with a title slug is not);
- is about another thing with the same name: when the query's entity is a single
  word (*Block*, *Unity*, *Arm*), a result whose domain is not the entity's and
  whose title has the word inside a longer proper-noun phrase, led by a
  capitalised *The* (*The Block*) or following another capitalised word (*Cinder
  Block*), is `wrong_entity`. Possessives (*Dorsey's Block*), corporate suffixes
  (*Block, Inc.*) and freshness words don't count as a longer name;
- repeats another result's page;
- for an announcement query in a window (*announce*, *announcement*, *press
  release*, *launch*), is not an article: it passes only with a verified in-window
  date or an article-like path (a date in the path; a `news`, `press`, `blog`,
  `stories`, `announcements`, `releases`, `articles`, `updates`, `insights` or
  `media` segment followed by a slug of three or more hyphenated words or an id;
  or any slug of four or more words). Product, pricing, careers, platform, sign-in,
  investor overview, filings, results and category pages, listings (`?l=`,
  `?page=`), profiles and homepages fail as `not_article`, so the ladder climbs
  instead of returning them;
- for a code query, is a fork or an archived repository, is in a language the query
  does not name (when it names one and GitHub knows the repository's), or has too
  few stars: under 500 for a need (*library for X*, *X framework*), under 100 for a
  name lookup unless the repository carries the name.

With a `recency` window, results that carry no date are not left to guess at:
the pages of up to `search_date_reads` (default 6) undated results that would make
the top are read at once over plain http (`search_date_read_timeout_seconds`,
default 5; no paid tools, the normal per-origin pacing), and the publication date
in the page's own metadata (`article:published_time`, JSON-LD `datePublished`,
`<time datetime>`; never a modified date) is set as the result's `published`
with `date_source: "page"`. Results now provably outside the window drop out;
results that still have no date stay, ranked below verified ones, and count for
at most half of `search_good_results`, so the ladder keeps climbing instead of
settling for undated filler. `receipt.search_checks.date_reads` reports
`tried`, `dated`, `dropped`, `latency_ms` and `cost_usd`. `search_date_reads: 0`
turns this off.

When any result's date is verified inside the window, results whose date could
not be verified leave `results` and come back apart as `unverified_results`: the
answer holds only what is known to be fresh, and nothing is hidden.
`search_hold_undated: false` mixes them back in, ranked last. So that holding
results back does not leave the answer short, a good windowed answer with fewer
verified results than `limit` asks up to `search_fill_rungs` (default 2) more free
sources and merges what passes.

Weak sets are not wasted: passing results from earlier sources are carried up,
merged and deduplicated, and the search ends as soon as the sources together have
enough. Paid sources join only with `allow_paid_fallbacks`, after
`search_paid_after_weak` free sources (default 2) came back weak, cheapest
likely success first, except for the queries below. A free source with no answer
after `search_hedge_after_seconds` (default 3) is raced by the next free one; the
first set that passes wins. `bing_rss` is the last web source and never races:
when its results share nothing with the query it counts as failed, not as an
answer. `search_max_seconds` and `search_max_sources` cap the climb.

### Ranking

Passing results are ordered within each date tier by a relevance score
(`check.relevance`). From the strongest signal down:

1. the entity, or every key term, in the title;
2. the result being the thing itself: its domain, or its GitHub `owner/repo`, is
   the entity or project name (among repositories of that name, more stars first);
3. for news and announcement queries, the entity's own site, and a press or news
   path on it;
4. key terms only in the snippet.

Pages that are not what a search is after count against a result, from their URL
and title alone, unless the query asks for that kind of page: stock quotes, share
prices and liveblogs; policy and legal pages; release notes and documentation
(for news and announcement queries); security advisory listings and news
aggregator pages (the same); and *awesome-* lists and paper digests (for paper
queries). They rank below every ordinary passing result. The source's own order
breaks ties.

Code queries add their own ordering. A query that asks for the repository (*github*,
*repo*) prefers repository pages (`owner/name`) to an organisation's page or a
project's website; repositories named *demo*, *example(s)*, *sample(s)*,
*template*, *starter*, *boilerplate*, *tutorial*, *benchmark(s)* or *awesome-\**
go last unless the query asks for them. For a name lookup (*httpx python github*)
the repository whose name is the project, owner first, leads, and repositories whose
owner/name does not hold the name as a word rank below those that do. For a need,
popular repositories and pages that name libraries lead, and a how-to guide
follows them.

For a fact question in the reference vertical, a Wikipedia article whose title is
not the question's topic (the topic of *who founded X* or *population of X* is X)
ranks below every passing web result, so it fills a slot only when nothing else is
left.

#### Source priors with paid search allowed

When paid sources are allowed, each result also carries the quality prior of the
source it came from (`check.prior`), weighed with relevance in the merge. A paid
source's prior is its bundled measured rate (`paid` in `bundled_wall_priors.json`);
free sources use defaults (SearXNG 0.75, arXiv 0.8, Stack Exchange 0.7, Bing News
and Wikipedia 0.6, GitHub 0.5, others 0.5), with Wikipedia 0.9 when the title is the
topic and GitHub 0.85 for the project asked for or a repository with 1000 stars. A
passing result of the best source therefore outranks a free one of similar
relevance; a canonical free result, or one with a verified date against an undated
paid one, can still lead. Results that fail the checks never count, whoever
returned them. Without paid sources the ordering is unchanged.

#### The answer starts from the paid source

When a paid source answered, the answer starts from its results, in its own order.
Each stays in place unless our checks fail it: off the query, outside the window,
the wrong entity, a home page, listing or non-article, a stock blurb, a challenge
page, or, for a code query, an organisation page or a project website when the
repository was asked for, or a demo, example, template or similar repository that
was not. A result that only ranks lower stays. The slots a failure leaves are
filled, in order, by the best passing results of the other sources (a short paid
set is filled the same way). For a name lookup or a reference question, a free
canonical result the paid set lacks (the project's own repository, the article
titled for the topic) takes a removed slot, or the last one. If no paid source
answered, or paid is not allowed, the merge above applies unchanged.
`receipt.search_ladder.anchor` records the source, how many results were kept,
which were replaced and why, and how many slots the other sources filled.

### Paid search in parallel

With `allow_paid_fallbacks`, an automatic search starts the cheapest
likely-success paid source beside the first free rung, instead of after the free
ones fail, whatever the kind of query. Everything is merged, checked and ranked,
and a paid result that fails the checks gives way to a passing free one.
`max_cost_usd` applies as always: a paid source that goes over the cap is
dropped and the free results stand. `search_paid_parallel: false` keeps paid
sources behind the free rungs. `receipt.search_ladder.paid_parallel` names the
source that was started early.

If the free sources make the answer good while that paid source is still
running, the search waits for it, up to `search_paid_wait_seconds` (default 10),
and anchors the answer on it. If it does not answer in time, the free answer
stands, `receipt.search_ladder.anchor` is null with `notes: ["paid_timeout"]`,
and the cancelled call is costed at its bundled price per search, marked
`cost_basis: "estimated_bundled_price"` on its attempt and listed in
`search_ladder.cost_estimated`. A source with no bundled price stays unknown.

### Filling a short answer

Without a window, when the local SearXNG is reachable and a good answer holds
fewer passing results than `limit`, one more free source (SearXNG first, if it has
not been asked) is asked and merged in. With a window, up to `search_fill_rungs`
more are, as above. Paid and last-resort sources are never asked to fill;
`search_fill_rungs: 0` turns filling off.

FrankenSurf remembers, per kind of query (vertical, recency or not, site filter
or not), which source passed the checks and tries it first next time
(`search_learned_routing`, stored in `search-stats.json` in the state directory).

Every result carries `check` (`passed`, `reasons`, `in_window`, `on_query`,
`published`, `date_source`, `kind`, `relevance`, and `prior` when paid sources are
allowed), and the receipt says what
happened:

```json
{
  "search_ladder": {"enabled": true, "query_type": "news|recent|open",
                    "order": ["bing_news_rss", "searxng", "duckduckgo_html"],
                    "first_rung": ["bing_news_rss", "searxng"],
                    "winner": "merged", "stopped": "good", "hedged": ["bing_news_rss", "searxng"]},
  "search_checks": {"verdict": "good", "need": 3, "passed": 3,
                    "reasons": {"off_query": 2, "out_of_window": 1},
                    "unknown_dates": 1,
                    "results": [{"url": "https://example.com/2026/10/11/story", "source": "bing_news_rss",
                                 "in_window": true, "on_query": true,
                                 "published": "2026-10-11T23:59:59Z", "date_source": "url", "kind": "item"}]},
  "search_attempts": [{"source": "bing_news_rss", "status": "observed", "count": 10, "passed": 2,
                       "check": "weak", "cost_usd": 0, "latency_ms": 412}]
}
```

`search_ladder: false` restores the first-answer behaviour. An explicit `source`
is asked once and its results are annotated but never dropped.

## Merge mode

`mode="merge"` asks every eligible source in the vertical at once (up to
`search_merge_sources`, default 4) and fuses their lists by reciprocal rank.
Duplicate pages (`www.`, trailing slashes and tracking parameters aside) merge
into one result that lists every engine that found it, with `fusion.sources`
giving each engine's rank. One blocked engine costs nothing, and a page found
by several engines rises. `receipt.search_merge` reports each source.

```python
results = await web.search("film camera repair sydney", mode="merge")
```

## Options

| Option | Default | Description |
| --- | --- | --- |
| `source` | automatic | One source only, by name (see the tables above). |
| `limit` | `10` | Number of results. |
| `site`, `exclude_domains`, `recency`, `region` | none | See above. |
| `vertical` | inferred | The kind of source. Inferred from the query when left out; an explicit value always wins. |
| `mode` | `fallback` | `merge` to ask every eligible source at once. |
| `search_source_prefer` | none | Try these sources first. |
| `search_source_allow` | all | Only these sources may run. |
| `search_source_timeout_seconds` | `8` | Time per source. |
| `allow_paid_fallbacks` | `false` | Let the paid sources join. |

  A search hit is an indexed candidate, not proof the page is live. Read it to
  find out.
