All skills
Skillintermediate

AI Search Gotchas

**Timestamp precision:** Use seconds (10-digit), not milliseconds. ```typescript const nowInSeconds = Math.floor(Date.now() / 1000); // Correct ```

Claude Code Knowledge Pack7/10/2026

Overview

AI Search Gotchas

Type Safety

Timestamp precision: Use seconds (10-digit), not milliseconds.

const nowInSeconds = Math.floor(Date.now() / 1000); // Correct

Folder prefix matching: Use gte for "starts with" on paths.

filters: { column: "folder", operator: "gte", value: "docs/api/" } // Matches nested

Filter Limitations

LimitValue
Max nesting depth2 levels
Filters per compound10
or operatorSame column, eq only

OR restriction example:

// ✅ Valid: same column, eq only
{ operator: "or", filters: [
  { column: "folder", operator: "eq", value: "docs/" },
  { column: "folder", operator: "eq", value: "guides/" }
]}

Indexing Issues

ProblemCauseSolution
File not indexedUnsupported format or >4MBCheck format (.md/.txt/.html/.pdf/.doc/.csv/.json)
Index out of sync6-hour index cycleWait or use "Force Sync" (30s rate limit)
Empty resultsIndex incompleteCheck dashboard for indexing status

Auth Errors

ErrorCauseFix
AutoRAGUnauthorizedErrorInvalid/missing tokenCreate Service API token with AI Search permissions
AutoRAGNotFoundErrorWrong instance nameVerify exact name from dashboard

Performance

Slow responses (>3s):

// Add score threshold + limit results
ranking_options: { score_threshold: 0.5 },
max_num_results: 10

Empty results debug:

  1. Remove filters, test basic query
  2. Lower score_threshold to 0.1
  3. Check index is populated

Limits

ResourceLimit
Instances per account10
Files per instance100,000
Max file size4 MB
Index frequency6 hours

Anti-Patterns

Use env vars for instance names:

const answer = await env.AI.autorag(env.AI_SEARCH_INSTANCE).aiSearch({...});

Handle specific error types:

if (error instanceof AutoRAGNotFoundError) { /* 404 */ }
if (error instanceof AutoRAGUnauthorizedError) { /* 401 */ }