CormorantDocs
Menu

Search in depth

POST /v1/search answers a query with merged, deduplicated results from several search engines, falling back to a search API only when it has to.

Request#

JSON
{
  "query": "Nestlé sustainability report 2025",
  "language": "en",
  "country": "CH",
  "max_results": 20,
  "freshness": "month",
  "cache_ttl_s": 86400,
  "project_ref": "company:4711",
  "safesearch": "moderate",
  "entity": "cmp_01JA2B3C4D5E6F7G8H9J0KMNPQ",
  "entity_filter": false
}

Only query is required. language is a BCP 47 tag (en, de-CH, zh-Hans, zh-Hant-TW) or a name such as taiwanese, country ISO 3166-1 alpha-2, max_results 1–50 (default 20), freshness one of day, week, month, year. limit and search_lang are accepted for max_results and language.

Without language, country sets it to the country's main language (US, GB, AU: English, DE, AT: German, JP: Japanese, and so on; countries with several, such as CH, BE, CA and IN, search in any language). Before 5 Nov 2026 country alone reached the engines without a language, and they answered in the language of our servers' location.

Precision#

  • Safe search is moderate by default (off, moderate, strict). Unless it is off, results on well-known adult sites are removed as well (filtered.adult).
  • OR alternatives are put in parentheses before searching, so that "W.W. Grainger" animal testing OR "animal welfare" is searched as "W.W. Grainger" (animal testing OR "animal welfare") and the company name stays required on every engine. engine_query shows what was searched; "group_or": false sends your query as is. The exact rules are in the API contract.
  • Entity hint: entity (a register cmp_ id, a domain, or {"id", "domains", "names"}) puts results on the company's own domains or naming it first and marks each result's entity_match (domain, name, none); entity_filter: true drops the none results.
  • Operators are checked, not trusted to the engines (operators shows what was read from the query):
    • site:host keeps only results on that host and its subdomains (filtered.site); several site: terms are alternatives, -site: excludes. With nothing on the site the answer is empty with empty_reason: "nothing_on_site" (or "all_filtered" when results elsewhere were removed), never results from other hosts.
    • A quoted phrase must appear as a phrase in a result's title, snippets or URL (case, punctuation, &/and and a trailing legal form such as Inc. are ignored); results without it are dropped (filtered.phrase). "strict_operators": false keeps them.
    • When the engines' answer ignores a phrase or site:, or most results match at most one term of a longer query (the engine searched one generic word), the search goes to the fallback (fallback_reason: "operators_ignored") and the ignored answer is not merged in. Operators that no provider honoured are listed in operators_ignored.
    • OR groups are passed on with their parentheses (see group_or).
  • Empty answers say why: filtered_out counts every result removed by a filter, filter_reason names the filter that removed most (not_on_site, phrase_missing, entity_unmatched, adult_site), and empty_reason tells "nothing found" (nothing_found, nothing_on_site) from "everything found was unrelated" (all_filtered).

Several languages#

Sources in other languages rarely show up for an English query. With languages, one request searches each language in its own market and merges the results:

JSON
{
  "query": "Tencent annual report",
  "query_language": "en",
  "languages": ["en", "zh-Hans", "zh-Hant-TW"],
  "entity": "cmp_01JA2B3C4D5E6F7G8H9J0KMNPQ",
  "translate_to": "en"
}
  • The query for each language is your query where it already is in that language, the company's own name from the register where the query only names the entity, or a machine translation (operators such as site:, domains and identifiers are kept as written). queries_used shows what was searched; queries sets it yourself ({"zh-Hans": "腾讯 年报"}). Simplified and Traditional Chinese are converted into each other without machine translation.
  • Each language is searched in its market: the tag's region (zh-Hant-TW in Taiwan), regions, or the language's main market (ja in Japan, ko in Korea); en, fr, es and pt have none by default.
  • A page found in several languages counts once (found_in), and the languages take turns in the list, so one cannot crowd out the others. per_language_limit caps each language's share.
  • translate_to adds translation (title and snippets) to results in other languages, billed as machine translation (fast tier).
  • Each language counts as one search; languages[] shows each one's provider, results and request_id.

Providers and fallback#

  1. Shared cache — keyed by the normalised query as searched (engine_query, whitespace collapsed, lower case) and its operators plus language, country, freshness and safesearch. An entry keeps the engines' whole answer (up to 50 results, before any filter) and serves any max_results, entity and filter: those are applied per request. Entries live 7 days; less with freshness (day 2 hours, week 12 hours, month 2 days), when nothing was found (24 hours) or when some engines did not answer (12 hours). cache_ttl_s caps the age you accept; 0 bypasses the cache. Identical searches that arrive together are searched once.

  2. SearXNG — Cormorant's own metasearch instances (Bing, Yahoo, Wikipedia, Bing News; Baidu and Sogou as well for Simplified Chinese). A standard route. Wikipedia does not count towards the two answering engines below.

  3. Fallback search services, used in turn when SearXNG

    • fails or times out (fallback_reason: searxng_error, searxng_timeout, no_searxng_instance),
    • reports unresponsive engines and fewer than two engines answered (unresponsive_engines, or captcha_engines when an engine was CAPTCHA-blocked), also after a second SearXNG instance was asked (engines limit each instance separately; both answers are combined), or
    • returns fewer than 3 usable results (too_few_results), or
    • ignores the query's phrase, site: or most of its terms (operators_ignored, see Precision).

    The first is a partner search index with its own web index (where activated; queries are processed outside Switzerland and the EU). When its answer has fewer than 3 usable results or ignores the operators too, the Brave Search API is asked. Leave the partner index out of a search with "exclude_providers": ["partner_index"] (the fallback then goes straight to Brave), or ask support to leave it out of every search of a project.

provider says who answered (searxng, partner_index or brave), answered_by which engines the served results came from (bing, yahoo, partner_index, brave_api), fallback_reason why the fallback was considered, degraded: true that Cormorant's own engines did not answer well (a fallback was needed or engines failed), and unresponsive_engines which SearXNG engines failed for this query. When a fallback is used, its results come first (Brave's before the partner index's when both were asked), followed by results only SearXNG found (none when SearXNG ignored the operators).

If the fallbacks are unavailable or your project's budget is exhausted, whatever SearXNG returned is served (and not cached) with fallback_reason set. A search that the engines answered but that found nothing returns results: [] with error: null. Only when the providers could not answer is error set — for example budget_exhausted, brave_http_429 or searxng_timeout.

Results: nothing is lost#

Results are deduplicated by normalised URL (scheme, www., trailing slash and tracking parameters ignored). For each URL, every distinct snippet and every engine that returned it is kept, in order of first appearance:

JSON
{
  "url": "https://www.nestle.com/sustainability/reporting",
  "title": "Creating Shared Value and Sustainability Report 2025",
  "snippets": ["Our 2025 report covers ...", "Download the full report ..."],
  "engines": ["bing", "yahoo", "brave_api"],
  "published_at": "2026-03-02T00:00:00",
  "rank": 1
}

More engines agreeing on a URL is a useful relevance signal; more snippets give an LLM more context before it decides to fetch the page.

Costs#

SearXNG answers and cache hits are standard routes with no provider cost (billed as search and search_cached). A fallback call (search_fallback) costs a small fixed amount per request (operator-configured: under a tenth of a cent for the partner index, on the order of half a cent for Brave), shown in cost_usd and charged to your project's budget. A partner index call that finds nothing costs nothing. Rate limits are retried by Cormorant and never billed.

Examples#

curl
curl -sS https://api.cormorant.ch/v1/search \
  -H "Authorization: Bearer $CORMORANT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query": "Holcim annual report 2025", "language": "en", "freshness": "year", "max_results": 10}'
Python
answer = client.post(
    "/v1/search",
    json={
        "query": "Holcim annual report 2025",
        "language": "en",
        "freshness": "year",
        "max_results": 10,
    },
).json()
if answer["error"]:
    print("search failed:", answer["error"])
for hit in answer["results"]:
    print(f"{hit['rank']:>2} {hit['title']} ({', '.join(hit['engines'])})\n   {hit['url']}")
TypeScript
const answer = await (
  await fetch(`${BASE}/v1/search`, {
    method: "POST",
    headers,
    body: JSON.stringify({ query: "Holcim annual report 2025", language: "en", freshness: "year", max_results: 10 }),
  })
).json();
for (const hit of answer.results) console.log(hit.rank, hit.title, hit.url, hit.engines.join(","));

Tips#

  • Searching is cheap; fetching is where the time goes. Use the snippets to decide which results deserve a fetch.
  • Keep max_results as small as you need: it is part of the cache key, so consistent values also mean more cache hits. Keep volatile parts (dates, run ids) out of the query; see Caching and reuse across runs.
  • For many queries use POST /v1/batch/search — see Sync vs batch.

View as Markdown