The Ontology Layer · Reference

Search

One ranked answer fused across every source for a natural-language query.

search is the workhorse: one natural-language query, fanned across every source in parallel, fused into a single ranked list. A technical reader can predict the response shape exactly from this page.

http
POST /projects/{project_id}/knowledge/search

Request body

json
{
  "query": "where do we validate a session token?",
  "sources": ["code", "docs"],
  "providers": null,
  "repo_id": null,
  "since": null,
  "top_k": 10,
  "group_by_source": false
}
FieldTypeDefaultNotes
querystringRequired. Natural language.
sourcesstring[] \nullnullRestrict to these sources; omit for all.
providersstring[] \nullnullRestrict to these providers.
repo_idstring \nullnullRestrict to a single repo.
sincestring \nullnullISO-8601 lower bound for time-bearing sources.
top_kint10Clamped to 1–50.
group_by_sourceboolfalseReturn top_k per source instead of one fused list.

Response — fused (default)

json
{
  "query": "where do we validate a session token?",
  "results": [
    {
      "source": "code",
      "provider": null,
      "ref": "code|acme__platform__main|acme__platform__src/auth/session.py",
      "title": "session.py — validate_session",
      "snippet": "def validate_session(token: str) -> Principal: ...",
      "score": 0.82,
      "url": null,
      "timestamp": null,
      "resource_uri": "ontology://acme/code/...",
      "metadata": {}
    }
  ]
}

When group_by_source is true, the payload is { "query": ..., "grouped": { "code": [ ...hits ], "docs": [ ...hits ] } } with up to top_k hits per source instead of one results array.

If nothing matches, the response includes a no_results_help object suggesting what to try next.

How results are ranked

The query is embedded once and shared with every retriever. Because sources score on incompatible scales — cosine similarity, keyword relevance, recency — the fused list is built with Reciprocal Rank Fusion, not raw scores, so the top of every source is represented fairly. See Ranking & fusion.

Each result's ref is opaque; pass it to fetch to get the full object.

Next: Fetch.