tobi/qmd · error · Error

No indexed documents found.\nIndex a collection with 'qmd co

Error message

No indexed documents found.\nIndex a collection with 'qmd collection add' / 'qmd update' before running bench.

What it means

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.

Source

Thrown at src/bench/bench.ts:306

    const match = collections.find(c => c.name === collection);
    if (!match) {
      const names = collections.map(c => c.name);
      const hint = names.length > 0
        ? `Available: ${names.join(", ")}. Run 'qmd ls' to inspect.`
        : "Run 'qmd ls' to see available collections.";
      throw new Error(`Collection not found: ${collection}\n${hint}`);
    }
    if (match.active_count === 0) {
      throw new Error(
        `Collection '${collection}' has no indexed documents.\nRun 'qmd update', then 'qmd ls ${collection}' to confirm files are indexed before bench.`,
      );
    }
    return;
  }

  const total = collections.reduce((n, c) => n + c.active_count, 0);
  if (collections.length === 0 || total === 0) {
    throw new Error(
      "No indexed documents found.\nIndex a collection with 'qmd collection add' / 'qmd update' before running bench.",
    );
  }
}

export function benchSummaryAllZero(
  summary: BenchmarkResult["summary"],
): boolean {
  const entries = Object.values(summary);
  if (entries.length === 0) return false;
  return entries.every(s => s.avg_precision === 0 && s.avg_recall === 0 && s.avg_mrr === 0);
}

export function allZeroBenchWarning(collection?: string): string {
  const lsHint = collection ? `qmd ls ${collection}` : "qmd ls";
  return `All benchmark scores were 0.00 — the collection is likely unindexed or the fixture's expected files are missing. Check with '${lsHint}'.`;
}

View on GitHub (pinned to dbfd0b4736)

Solutions

  1. Add a collection: `qmd collection add <path> --name <name>`
  2. Run `qmd update` to index documents, verify with `qmd status`
  3. Then re-run `qmd bench fixture.json` (or scope with -c <name>)

Example fix

# before
qmd bench bench/fixture.json
# after
qmd collection add ~/notes --name notes
qmd update
qmd bench bench/fixture.json -c notes
Defensive patterns

Strategy: validation

Validate before calling

const out = execSync('qmd status').toString(); // or parse collection list
if (!/indexed|\d+ docs/i.test(out)) throw new Error('index empty: run qmd collection add + qmd update');

Try / catch

try { await runBenchmark(...) } catch (e) { if (e.message.includes('No indexed documents')) { /* run setup: collection add + update, then retry */ } }

Prevention

When it happens

Trigger: Fresh install: `qmd bench fixture.json` before any `qmd collection add` / `qmd update` has populated ~/.cache/qmd/index.sqlite.

Common situations: New machine or CI environment where the global index was never built; the index cache was cleared.

Related errors


AI-assisted analysis of tobi/qmd@dbfd0b4736 (2026-08-28). Data as JSON: /api/errors/2a5cf1f21d944551. Report an issue: GitHub.