Skip to content

admin_reindex_all ​

Backfill Cloudflare Vectorize embeddings for all existing contexts across every project in one call.

Overview ​

admin_reindex_all is a cross-project version of reindex_project. It iterates every context in D1 — regardless of project — and writes vector embeddings to Vectorize. Run it once after initial setup or after adding Vectorize to an existing deployment.

Added: v3.6.0

Layer: Infrastructure / Admin

Purpose: One-shot Vectorize backfill across all projects


Parameters ​

None. No arguments required.


Returns ​

A count of indexed contexts broken down by project:

Reindexed 47 contexts across all projects — semantic search now covers all historical snapshots.

By project:
  - wake-intelligence: 12
  - api-service: 23
  - mobile-app: 8
  - home-wake-test: 4

If the Vectorize index is not configured or no contexts exist:

No contexts reindexed. Either no contexts exist or the vector index is not configured.

When to Use ​

After Initial Deployment ​

The first time you connect Wake Intelligence to Vectorize, existing contexts have no embeddings. admin_reindex_all seeds the index in one call.

After a Vectorize Outage ​

If Cloudflare Vectorize was unavailable when contexts were saved, those contexts fell back to keyword-only search. Reindex to restore semantic coverage.

When Semantic Search Returns Nothing ​

If natural language queries consistently return no results, the Vectorize index is likely empty or sparse. Run this to restore full semantic search.


Example ​

typescript
admin_reindex_all()
Reindexed 47 contexts across all projects — semantic search now covers all historical snapshots.

By project:
  - my-project: 31
  - side-project: 16

How It Works ​

Internally, admin_reindex_all:

  1. Fetches all contexts from D1 (up to 2,000)
  2. For each context, generates a vector embedding from its AI-summarized text using @cf/baai/bge-base-en-v1.5
  3. Upserts the vector into the wake-context-embeddings Vectorize index with the project as metadata
  4. Returns a count per project

Contexts that already have embeddings are overwritten with fresh ones (upsert is idempotent).


Performance ​

  • Processes up to 2,000 contexts per call
  • ~500ms per 10 contexts (embedding generation via Workers AI dominates)
  • For large deployments, prefer running during low-traffic periods

vs. reindex_project ​

reindex_projectadmin_reindex_all
ScopeSingle projectAll projects
Argumentsproject (required)None
Use caseTargeted backfillInitial setup, full reset

See Also ​