Skip to the page

Learn · Models & search

Vector & hybrid search

Declare vector and full-text indexes on your types. Searches apply the caller’s access rules during the scan.

CLI
—

Vector and full-text indexes#

using extension napalm; brings the AI extension. Every project can attach deferred semantic vector indexes (ext::ai::index) to any object type alongside built-in full-text indexes (fts::index). A schema may declare using extension ai; too. Writes commit immediately, and Napalm computes embeddings asynchronously in the background through the project’s model provider. See Models and embeddings to configure model providers and spend caps.

Deferred embedding
Writes commit immediately while Napalm embeds indexed text asynchronously through the project’s provider.
In-scan policy check
Access policies evaluate during vector scoring so top-k always returns k rows the caller may read.
Hybrid RRF fusion
Reciprocal rank fusion merges semantic proximity and PostgreSQL full-text rank in one query.
dbschema/default.gel
using extension auth;using extension ai;using extension napalm;using future simple_scoping; module default {  type Note {    required title: str;    body: str;     deferred index ext::ai::index(embedding_model := 'text-embedding-3-small')      on (.title ++ ' ' ++ (.body ?? ''));    index fts::index on (      fts::with_options(.title ++ ' ' ++ (.body ?? ''), language := fts::Language.eng)    );     access policy anyone_can_read      allow select;  }}
Index or functionPurposeWhen to use
deferred index ext::ai::indexSemantic vector similarityWhen to useConceptual questions, paraphrases and multilingual recall across notes, tickets or passages.
index fts::indexFull-text index, ranked by PostgreSQLWhen to useExact identifiers, SKUs, function names, error codes and quoted phrases.
ext::ai::hybrid_searchReciprocal rank fusion (RRF)When to useQueries that combine conceptual similarity and exact keyword matching in one ranking.

Semantic and hybrid search queries#

ext::ai::search ranks an indexed type by semantic proximity, while ext::ai::hybrid_search fuses semantic similarity and exact lexical terms using reciprocal rank fusion (RRF). Both functions return only the rows the caller may read.

In-scan policy checks and reciprocal rank fusion

ext::ai::search and ext::ai::hybrid_search evaluate your schema’s select policies during candidate scoring, then fuse vector distance with fts::index lexical rank into one top-k result.

Deployed and ad-hoc statements sent to the API may call both search functions, plus ext::ai::to_context to inspect the text an index embeds. No other function of ext::ai is open to API statements.

dbschema/queries/similarNotes.edgeql
with found := (  select ext::ai::search(Note, <str>$words)  order by .distance  limit 5)select (for hit in found union { title := hit.object.title, distance := hit.distance })order by .distance
The query
Pass text as <str>$words for the index’s model to embed, or pass a precomputed vector as <array<float32>>$embedding.
Order and limit
Wrap the search in a select with order by .distance and a limit. For ext::ai::hybrid_search, sort with order by .score desc. The limit caps the rows returned.
Not in a schema function
A schema function cannot wrap a search because function arguments are not query parameters. Deploy the statement as a query file instead.

The search route and MCP search#

POSThttps://<label>.napalmdata.com/search

Every project exposes a POST /search HTTP endpoint, a matching client.search() SDK method and an MCP search tool. The endpoint embeds the query string, runs a hybrid RRF search against a type with both an ext::ai::index and an fts::index, and returns matches under the caller’s select access policies.

Hybrid RRF search across HTTP, SDKs and MCP

POST /search, client.search() and the MCP search tool fuse ext::ai::index semantic proximity with fts::index lexical rank under the caller’s select policies.

POST /search
{  "type": "Note",  "query": "Q3 enterprise pricing tiers",  "fields": ["title"],  "limit": 10}

A project without a model provider for the type’s index returns 409 model_not_configured. The route never silently degrades to keyword-only search.

POST /search accepts only callers permitted by your branch’s passthrough mode, configured with napalm endpoint or in the console. User sessions receive 403 deployed_query_required when passthrough is keys, and all callers receive 403 deployed_query_required when passthrough is none (or when a service key or agent grant is restricted to named deployed queries). These callers search through a deployed query. Write the search as a query file, as in Semantic and hybrid search queries, and deploy the file with your own filters.

See Project API: POST /search for complete request and response fields. In-app AI copilots covers pairing hybrid retrieval with POST /ask and dry-run mutation approvals.

Access checks and index size#

Callers reach embeddings through each record according to its access policies, and Napalm evaluates those policies during candidate scoring. Standalone vector stores fetch a global top-k first and strip unauthorized hits afterward, returning fewer than k results whenever restricted rows occupy the top ranks.

Vector index plane

ext::ai::index evaluates select policies during candidate scoring rather than post-filtering, returning k permitted neighbors from small workspaces past 100M vectors.

Snapshot-consistent search queries

Deployed search queries read the active SQL transaction snapshot directly, so newly embedded records appear immediately and revoked records vanish in the same commit.

Small workspaces
When access rules narrow a caller to a single user, project or small workspace, search scores every permitted row directly so no match is missed.
Fresh rows
Search reads the query’s own transaction snapshot, so a newly written record appears in semantic results as soon as its embedding commits.
Any index size
An index scales from a handful of rows past 100 million vectors with no schema changes.
Same-commit revocation
Unsharing or deleting a record removes it from vector search, full-text search, live subscriptions and EdgeQL queries in the same commit.

For distance metrics (Cosine, InnerProduct, L2) and custom dimensionality, see the AI extension reference and Models and embeddings.

Type a word or two to search every docs page.