Skip to content

search matches IDs as substrings: "R-021" finds and can rank "ADR-021" first #302

Description

@raifdmueller

Version: dacli 0.4.38 (commit 34beaa2)

Problem

search matches substrings. Looking up a short identifier also matches every identifier that contains it: R-021 matches ADR-021, CR-021 and so on. Title matches score higher than body matches, so a section that merely contains the ID in its title can outrank the one you're looking for. For LLM agents that navigate arc42 docs by risk, ADR or requirement IDs, this leads to reading and editing the wrong section.

Reproduction

= Decisions

== ADR-021 Use a cache

We cache results.

== Risks

=== Stale data

See R-021 in the risk list.
dacli --docs-root docs search "R-021"

Expected

Only the "Stale data" section, or at least that section ranked first.

Actual

path: doc:adr-021-use-a-cache    score: 0.968   context: ADR-021 Use a cache
path: doc:risks.stale-data       score: 0.607   context: === Stale data See R-021 in the risk list.

(When R-021 is also in a heading, it ranks first, 1.0 vs 0.968, but ADR-021 is still returned.)

Proposal

Add a --word (word-boundary) or --exact option to search and the MCP search tool. With it, R-021 would match only where it isn't preceded or followed by an alphanumeric character or -. A cheaper alternative: rank whole-word matches above substring matches by default.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions