Search by meaning (RAG)
plugins: [semantic({ collections: ["posts", "pages"] })] + the Workers AI binding. Published content is split into chunks (per language), turned into vectors with @cf/google/embeddinggemma-2 and indexed on publish, unpublish or delete.
- Site:
Astro.locals.cms.semanticSearch("fabrics for a wedding dress", { collections, locale, limit })orGET /api/cms/semantic?q=…. Returns title, chunk and URL, read with the searcher's access. - Panel: a "By meaning" button next to the list search.
- MCP: the
search_contenttool. - Ask the content:
POST /api/cms/semantic/ask { question }→{ answer, sources }with [n] citations (needsai()). Staff use their AI cap; visitors only withask: { public: true }, withdailyLimitPerVisitor(20) per IP per day. - Where the vectors live: by default in D1 (compares up to 5000 chunks in memory: small sites). For more, a Vectorize index:
wrangler vectorize create <site>-vectors --dimensions=768 --metric=cosineand in wrangler.jsonc"vectorize": [{ "binding": "CMS_VECTORS", "index_name": "<site>-vectors" }]. Vectorize does not run locally. - Reindex (when turning the plugin on for a site with content, or after changing
fields):POST /api/cms/semantic/reindexas an admin. - Migration
0008.