Skip to content

search: multiple terms are OR, but the help text documents AND #425

Closed

Description

@dubadub

cook search's help text states:

Multiple terms are treated as AND (all must match)

The behaviour is OR: adding a term widens the result set rather than narrowing it.

Reproduction

printf 'Roast @chicken{1} with @thyme{2%%sprigs}.\n' > chicken.cook
printf 'Boil @rice{200%%g} in @water{1%%l}.\n' > rice.cook

cook search chicken
# "chicken.cook"

cook search chicken rice
# "chicken.cook"
# "rice.cook"

Under the documented AND semantics the second command would return nothing, since neither recipe contains both terms.

Cause

cooklang-find's count_matches sums each term's occurrence count and keeps any file scoring above zero, so any single matching term is enough.

Question for maintainers

This is really two things, and only the first is unambiguous:

  1. The documentation was wrong. That is being corrected in the library-extraction branch — the help text and docs/search.md now describe OR.
  2. Whether the behaviour should change to match the original documented intent is a product decision. Narrowing on additional terms is the more common convention and is what the help text promised, but changing it would alter results for existing users.

Filing so the second question gets decided deliberately rather than settled by whichever text someone reads first.

Noticed while extracting search into a library crate, where the semantics had to be pinned by tests.

Activity

  1. added
    help wanted
    on Aug 13, 2026
  2. added a commit that references this issue on Aug 31, 2026
    ade5e0a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions