Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Comprehensive Cloudflare platform skill covering Workers, D1, R2, KV, AI, Durable Objects, and security.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/ai-search/gotchas.md
1# AI Search Gotchas23## Type Safety45**Timestamp precision:** Use seconds (10-digit), not milliseconds.6```typescript7const nowInSeconds = Math.floor(Date.now() / 1000); // Correct8```910**Folder prefix matching:** Use `gte` for "starts with" on paths.11```typescript12filters: { column: "folder", operator: "gte", value: "docs/api/" } // Matches nested13```1415## Filter Limitations1617| Limit | Value |18|-------|-------|19| Max nesting depth | 2 levels |20| Filters per compound | 10 |21| `or` operator | Same column, `eq` only |2223**OR restriction example:**24```typescript25// ✅ Valid: same column, eq only26{ operator: "or", filters: [27{ column: "folder", operator: "eq", value: "docs/" },28{ column: "folder", operator: "eq", value: "guides/" }29]}30```3132## Indexing Issues3334| Problem | Cause | Solution |35|---------|-------|----------|36| File not indexed | Unsupported format or >4MB | Check format (.md/.txt/.html/.pdf/.doc/.csv/.json) |37| Index out of sync | 6-hour index cycle | Wait or use "Force Sync" (30s rate limit) |38| Empty results | Index incomplete | Check dashboard for indexing status |3940## Auth Errors4142| Error | Cause | Fix |43|-------|-------|-----|44| `AutoRAGUnauthorizedError` | Invalid/missing token | Create Service API token with AI Search permissions |45| `AutoRAGNotFoundError` | Wrong instance name | Verify exact name from dashboard |4647## Performance4849**Slow responses (>3s):**50```typescript51// Add score threshold + limit results52ranking_options: { score_threshold: 0.5 },53max_num_results: 1054```5556**Empty results debug:**571. Remove filters, test basic query582. Lower `score_threshold` to 0.1593. Check index is populated6061## Limits6263| Resource | Limit |64|----------|-------|65| Instances per account | 10 |66| Files per instance | 100,000 |67| Max file size | 4 MB |68| Index frequency | 6 hours |6970## Anti-Patterns7172**Use env vars for instance names:**73```typescript74const answer = await env.AI.autorag(env.AI_SEARCH_INSTANCE).aiSearch({...});75```7677**Handle specific error types:**78```typescript79if (error instanceof AutoRAGNotFoundError) { /* 404 */ }80if (error instanceof AutoRAGUnauthorizedError) { /* 401 */ }81```82