{"record":{"id":"2a5cf1f21d944551","repo":"tobi/qmd","slug":"no-indexed-documents-found-nindex-a-collection-wi","errorCode":null,"errorMessage":"No indexed documents found.\\nIndex a collection with 'qmd collection add' / 'qmd update' before running bench.","messagePattern":"No indexed documents found\\.\\\\nIndex a collection with 'qmd collection add' / 'qmd update' before running bench\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/bench/bench.ts","lineNumber":306,"sourceCode":"    const match = collections.find(c => c.name === collection);\n    if (!match) {\n      const names = collections.map(c => c.name);\n      const hint = names.length > 0\n        ? `Available: ${names.join(\", \")}. Run 'qmd ls' to inspect.`\n        : \"Run 'qmd ls' to see available collections.\";\n      throw new Error(`Collection not found: ${collection}\\n${hint}`);\n    }\n    if (match.active_count === 0) {\n      throw new Error(\n        `Collection '${collection}' has no indexed documents.\\nRun 'qmd update', then 'qmd ls ${collection}' to confirm files are indexed before bench.`,\n      );\n    }\n    return;\n  }\n\n  const total = collections.reduce((n, c) => n + c.active_count, 0);\n  if (collections.length === 0 || total === 0) {\n    throw new Error(\n      \"No indexed documents found.\\nIndex a collection with 'qmd collection add' / 'qmd update' before running bench.\",\n    );\n  }\n}\n\nexport function benchSummaryAllZero(\n  summary: BenchmarkResult[\"summary\"],\n): boolean {\n  const entries = Object.values(summary);\n  if (entries.length === 0) return false;\n  return entries.every(s => s.avg_precision === 0 && s.avg_recall === 0 && s.avg_mrr === 0);\n}\n\nexport function allZeroBenchWarning(collection?: string): string {\n  const lsHint = collection ? `qmd ls ${collection}` : \"qmd ls\";\n  return `All benchmark scores were 0.00 — the collection is likely unindexed or the fixture's expected files are missing. Check with '${lsHint}'.`;\n}\n","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/tobi/qmd/blob/dbfd0b4736aeaf761d1a16ca8e424f071df8feb9/src/bench/bench.ts#L288-L324","documentation":"Thrown when running qmd bench without -c and the global index contains no documents at all across all collections. The unscoped bench mode searches everything, so an empty store cannot proceed.","triggerScenarios":"Fresh install: `qmd bench fixture.json` before any `qmd collection add` / `qmd update` has populated ~/.cache/qmd/index.sqlite.","commonSituations":"New machine or CI environment where the global index was never built; the index cache was cleared.","solutions":["Add a collection: `qmd collection add <path> --name <name>`","Run `qmd update` to index documents, verify with `qmd status`","Then re-run `qmd bench fixture.json` (or scope with -c <name>)"],"exampleFix":"# before\nqmd bench bench/fixture.json\n# after\nqmd collection add ~/notes --name notes\nqmd update\nqmd bench bench/fixture.json -c notes","handlingStrategy":"validation","validationCode":"const out = execSync('qmd status').toString(); // or parse collection list\nif (!/indexed|\\d+ docs/i.test(out)) throw new Error('index empty: run qmd collection add + qmd update');","typeGuard":null,"tryCatchPattern":"try { await runBenchmark(...) } catch (e) { if (e.message.includes('No indexed documents')) { /* run setup: collection add + update, then retry */ } }","preventionTips":["Make `qmd update` a setup step in CI before bench","Scope bench with -c so an empty global index fails clearly"],"tags":["bench","indexing","cli"],"backgroundTag":"empty-index","analyzedSha":"dbfd0b4736aeaf761d1a16ca8e424f071df8feb9","analyzedAt":"2026-08-28T18:07:46.628Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}