Skip to content

Document implicit-AND semantics of multi-term search queries #1843

Description

@Widthdom

Summary

SanitizeFtsQuery (DbSearchReader.cs:28-31) splits a multi-term query like cdidx search foo bar baz on whitespace and joins them into an FTS5 expression, producing implicit AND semantics. This works fine — but the behavior is documented nowhere. Users typing foo bar expect "match foo or bar" or "match the phrase foo bar" depending on their mental model from grep / Google / GitHub search, not "match files containing both foo and bar". The result: surprising empty results, then trial-and-error.

Where

  • src/CodeIndex/Database/DbSearchReader.cs:28-31 (SanitizeFtsQuery)
  • USER_GUIDE.md (search section — silent on this)

Suggested approach

(1) Document the implicit-AND behavior in the USER_GUIDE search section with a clear example: cdidx search foo barfoo AND bar (FTS5 semantics). (2) Add the same sentence to the search tool description (cross-link the just-filed #1810 — tool examples). (3) When the user provides multi-term input that returns zero results, surface a recovery hint (cross-link the just-filed #1812 — recovery hints): "No file contains all of: foo, bar, baz. Try --fts 'foo OR bar OR baz' to widen, or --phrase \"foo bar\" to require adjacency". (4) Add a --phrase flag (or document the existing FTS5 "foo bar" quoted-phrase syntax) for users who mean adjacency. (5) Cross-link with #1772 (kind taxonomy), #1582 (did-you-mean) — same family of "agent guesses wrong" gaps.

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