-
Notifications
You must be signed in to change notification settings - Fork 6
AI Search
Temp edited this page Feb 11, 2026
·
2 revisions
D1 Manager integrates with Cloudflare AI Search (formerly AutoRAG) to enable semantic search over your database schemas and data. Ask questions in natural language and get AI-generated SQL suggestions.
AI Search uses a D1βR2 connector pattern:
- Export - Your database schema and data are exported as markdown documents to R2
- Index - Cloudflare AI Search indexes these documents for semantic understanding
- Query - Ask questions in natural language or perform semantic searches
| Feature | Description |
|---|---|
| Compatibility Analysis | View table count, row count, and estimated export size |
| One-click Export | Export database schema and data to R2 in markdown format |
| Semantic Search | Find relevant tables, columns, and data based on meaning |
| AI-powered Search | Get AI-generated answers and SQL suggestions |
| Instance Management | List AI Search instances and trigger re-indexing |
-
R2 Bucket - AI Search exports require the
BACKUP_BUCKETbinding inwrangler.toml -
AI Binding - Add the
[ai]binding towrangler.toml:
[ai]
binding = "AI"- AI Search Instance - Create via Cloudflare Dashboard pointing to your backup bucket
- Open any database in D1 Manager
- Navigate to the AI Search tab
- Click Export to R2 to create searchable documents
The export creates:
-
schema.md- Full database schema with CREATE TABLE statements -
tables/{name}.md- Per-table documentation -
relationships.md- Foreign key relationships -
data/{name}.md- Full table data in markdown format
- Go to Cloudflare Dashboard > AI > AI Search
- Click Create AI Search
- Select your backup bucket as the data source
- Choose embedding and generation models (defaults recommended)
- Click Create
Wait for indexing to complete (shown on the instance overview page).
- Return to D1 Manager > AI Search tab
- Select your AI Search instance from the dropdown
- Choose search mode:
- AI Search - Get AI-generated answers with SQL suggestions
- Semantic Search - Find relevant documents based on meaning
- Enter your query and press Enter or click Search
| Query | Mode | Result |
|---|---|---|
| "How do I find users by email?" | AI | SQL query suggestion with explanation |
| "tables with timestamps" | Semantic | List of tables containing created_at, updated_at columns |
| "foreign key relationships" | Semantic | Documents describing FK constraints |
| "What columns are in the orders table?" | AI | Column list with types and constraints |
Exports are stored in your BACKUP_BUCKET at ai-search/{databaseId}/:
ai-search/
βββ {database-id}/
βββ schema.md # Full database schema
βββ relationships.md # FK relationships
βββ tables/
β βββ users.md # Per-table documentation
β βββ orders.md
βββ data/
βββ users.md # Full data (markdown table)
βββ orders.md
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/ai-search/compatibility/:dbId |
Analyze database for indexability |
POST |
/api/ai-search/export/:dbId |
Export database to R2 |
GET |
/api/ai-search/instances |
List AI Search instances |
POST |
/api/ai-search/instances/:name/sync |
Trigger re-indexing |
POST |
/api/ai-search/:name/search |
Semantic search |
POST |
/api/ai-search/:name/ai-search |
AI-powered search |
curl -X POST https://your-d1-manager/api/ai-search/export/{databaseId} \
-H "Content-Type: application/json" \
-d '{"databaseName": "my-database"}'curl -X POST https://your-d1-manager/api/ai-search/{instanceName}/ai-search \
-H "Content-Type: application/json" \
-d '{"query": "How do I query users by email?", "max_num_results": 10}'- Export your database first using Export to R2
- Create an AI Search instance in the Cloudflare Dashboard
- Point the instance to your backup bucket (
BACKUP_BUCKET) - Wait for indexing to complete
- Return to D1 Manager and refresh
Add the BACKUP_BUCKET binding to your wrangler.toml:
[[r2_buckets]]
binding = "BACKUP_BUCKET"
bucket_name = "d1-manager-backups"- Verify the export completed successfully
- Check that the AI Search instance status is "active" (not "indexing")
- Try triggering a sync using the refresh button next to the instance selector
- Ensure your query relates to content in your database
- R2 Backup Restore - R2 bucket configuration
- FTS5 Full Text Search - SQLite full-text search
- Query Console - SQL query execution
- Database Management
- R2 Backup Restore
- Scheduled Backups
- Table Operations
- Query Console
- Schema Designer
- Column Management
- Bulk Operations
- Job History
- Time Travel
- Read Replication
- Undo Rollback
- Foreign Key Visualizer
- ER Diagram
- Foreign Key Dependencies
- Foreign Key Navigation
- Circular Dependency Detector
- Cascade Impact Simulator
- AI Search
- FTS5 Full Text Search
- Cross Database Search
- Index Analyzer
- Database Comparison
- Database Optimization