Skip to content

Multi-collection search (-c A -c B) returns false empty or incomplete results in v1.0.7 #217

@1kuna

Description

@1kuna

Summary

In qmd 1.0.7, passing multiple -c/--collection flags can return 0 results (or too few) even when each collection returns results individually.

This appears to be caused by the current multi-collection implementation doing a global top‑K search (no collection constraint) and then post-filtering results to the requested collections. If the requested collections don’t appear in the global top‑K (common when you have a very large collection like chat logs), you get false empty results.

Affected commands in my testing:

  • qmd search (FTS/BM25)
  • qmd query (hybrid + rerank)
  • qmd vsearch (vector)

Environment

  • qmd binary: ~/.bun/bin/qmd
  • qmd --version: 1.0.7
  • Collections: 13 (includes one very large collection)
  • (In my setup) OpenClaw sidecar XDG paths were set for all commands:
XDG_CACHE_HOME=~/.openclaw/agents/main/qmd/xdg-cache \
XDG_CONFIG_HOME=~/.openclaw/agents/main/qmd/xdg-config \
~/.bun/bin/qmd …

Repro (FTS: qmd search)

Single collections work:

qmd search openclaw -c core --files -n 5
#6c98dc,0.00,qmd://core/tools.md
#1e1593,0.00,qmd://core/workspace.md
#bfd554,0.00,qmd://core/soul.md

qmd search openclaw -c skills --files -n 5
#cf37a8,0.00,qmd://skills/openclaw-ops/skill.md
#e8f0e8,0.00,qmd://skills/model-routing/skill.md
#184646,0.00,qmd://skills/keep/docs/releasing.md

Multiple -c can produce false empty:

qmd search openclaw -c core -c skills --files -n 5
No results found.

Another example (two other collections):

qmd search openclaw -c memory-dir-main --files -n 5
#e093fd,0.00,qmd://memory-dir-main/entities/openclaw.md
#5955b7,0.00,qmd://memory-dir-main/<redacted>/daily/2026-02-15.md
#9b5958,0.00,qmd://memory-dir-main/bank/world.md

qmd search openclaw -c memory-dir-main -c skills --files -n 5
No results found.

Observation that supports “top‑K then post-filter”: increasing -n (thus increasing candidate fetch) starts to surface results:

qmd search openclaw -c core -c skills --files -n 200 | head
#cf37a8,0.00,qmd://skills/openclaw-ops/skill.md

Repro (hybrid: qmd query)

Single collection works:

qmd query openclaw -c core --files -n 5 | tail -n 4
Reranking 3 chunks...
#… ,…,qmd://core/tools.md
#… ,…,qmd://core/workspace.md
#… ,…,qmd://core/soul.md

Multiple -c can produce false empty:

qmd query openclaw -c core -c skills --files -n 5 | tail -n 1
No results found.

Repro (vector: qmd vsearch)

Single collection works:

qmd vsearch openclaw -c openclaw-docs-main --files -n 5 | tail -n 2
#05a22b,0.76,qmd://openclaw-docs-main/zh-cn/reference/releasing.md
#7f3fc8,0.75,qmd://openclaw-docs-main/cli/setup.md

qmd vsearch openclaw -c chats-main --files -n 5 | tail -n 2
#… ,…,qmd://chats-main/<redacted>.md

Multiple -c returns only a subset (missing the other collection entirely):

qmd vsearch openclaw -c openclaw-docs-main -c chats-main --files -n 5 | tail -n 4
Searching 4 vector queries...
#… ,…,qmd://openclaw-docs-main/…
#… ,…,qmd://openclaw-docs-main/…

Expected vs actual

  • Expected: -c A -c B should constrain the search to A ∪ B (OR) before ranking/limiting, and return results from either collection (subject to scoring).
  • Actual: results depend on whether matches from the selected collections happen to appear in an unfiltered global top‑K; otherwise results are empty or incomplete.

Likely cause / relevant upstream change

Commit 640ac13 (“fix: support multiple -c collection filters in search commands”) is present in the v1.0.7 range.

That change adds multi‑-c support by:

  1. passing a collection filter only when exactly one collection is specified
  2. otherwise searching globally, then post‑filtering by qmd://{collection}/ prefix

This approach seems vulnerable to false empty/incomplete results due to candidate limits.

Workarounds

  • Run one search per collection and merge client-side (then re-rank if needed).
  • If acceptable, omit -c to search globally.

(For OpenClaw specifically: using searchMode: "query" with a single -c works fine; the issue only appears when multiple -c flags are provided.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions