Skip to content

Find an API operation when a word of its id has one typo - #4911

Merged
reakaleek merged 7 commits into
mainfrom
fix-api-search-title-typo-35748668
Nov 17, 2026
Merged

reakaleek merged 7 commits into
mainfrom
fix-api-search-title-typo-35748668

Conversation

@reakaleek

@reakaleek reakaleek commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

API search now lists the same operation first when one word of four letters or more has a typo. clustr health leads with "Get the cluster health status", as cluster health does.

Affects: Search, API reference

Prompt summary: Fix API search for a typo in a word of an operation's title. Add a failing judged case first, fix the ranking in a second commit, and diff the relevance report before and after to show nothing else regresses.

Why

clustr health lists "Get the cluster health" first and "Get the cluster health status" third. The word clustr matches no endpoint, id word, group or title word, so only the fuzzy field-name role explains it. That role scores the same on all three health operations, so they tie at 3.63 and the order is arbitrary. The title lift from #4908 cannot separate them, because all three titles carry both words.

What

A typo of an operation id word

Each plain word now also matches an operation id word within one edit. It uses the AUTO:4,100 fuzziness and one-letter prefix that field names already use (#4750), and it reads the existing api.words field. No mapping change and no reindex are needed.

A word typed whole beats one that starts another word

stats stems to stat, and the operation word role is a prefix match, so stat also began state and scored like a whole word. cluster stats tied cluster-stats with cluster-state at 11.63. The role now scores a whole word 2.0, a word that only begins another 1.8, and a typo 1.5, all under the id role name. Exact words keep their scores.

A weight between exact and approximate

OperationWordTypo is 1.5, between an exact id word (2.0) and the one-point roles. An exact word on one operation still beats a typo of it on another, and a typo of an id word still beats a word that only a title, group or field name carries. Both options share the id role name, so the result processor reads a typo as an operation word. A comment in ApiLookupWeights records the invariant.

A title within one edit

The title fingerprint is one token, so a fuzzy match on it measures the edit distance across the whole title. A typed text within one edit of a whole title earns TitleNamedTypo (2.0). The exact title is excluded from the lift, so an exact title keeps its score, and 2.0 sits below every endpoint key, so the lift only breaks ties. It fixes creat index, delte index and refesh index, whose title words a typo made unreachable. No mapping change is needed.

Judged cases

The first commit adds clustr health as a failing case, health cluster as a control, and four typo queries to the report. The third commit adds 15 of the most typed words, such as reindex, put mapping and snapshot create, and seven typo cases. Six of the typo cases fail on the commit before the fix: cluser health, clustr state, snaphot restore, snapshto restore, reindx and bulck. The popular words pass on both sides and guard the fix. cluster health, search knn, snapshot restore and get cluster settings were already judged.

Verify

Measured on the dev index. The "before" column is the commit that adds the failing case, and the "after" column is a local Debug build served through /v1/navigation-search.

Query Before (top three) After (top three)
clustr health health report, compact health summary, cluster health status cluster health status (4.63), health report, compact health summary
cluster health cluster health status, health report, compact health summary unchanged
health cluster cluster health status, health report, compact health summary unchanged
snapshot restor restore, create, get snapshot information unchanged

The report covers 98 queries and six changed their top three. No judged query changed its first result, and every exact query keeps its first score (cluster state stays at 11.63).

  • clustr health, clustr helth and serch knn now lead with the right operation. serch knn used to tie msearch with search.
  • cluster state lists cluster-stats second, ahead of cluster-reroute, because state is one edit from stats.
  • release isolated endpoint lists endpointisolateaction third, because isolated is one edit from isolate.
  • close index lists indices-clone third, because close is one edit from clone.

The first result of those three is unchanged. The new neighbours are the cost of a typo match, and each one is a plausible sibling.

The whole relevance suite on the dev index has 126 cases. It fails 19 on the first commit and 18 with the fix, and clustr health is the only difference. mise run test fails only the 9 Deploying snapshot tests that depend on the comma locale of the machine.

dotnet test --project tests/Elastic.Documentation.Api.Tests
# against a dev index; ApiSearchRelevanceReport is explicit, set API_SEARCH_REPORT_PATH to diff two runs
ENVIRONMENT=dev DOCS_BUILD_TYPE=assembler dotnet test --project tests-integration/Search.IntegrationTests/ --treenode-filter "/*/*/SearchRelevanceTests/ApiSearch*"

The integration cases are not run in CI. ApiSearchPlainWordDoesNotCoverTheRoutesUnderItsOwnName also fails on main.

The API cases pass 109 of 110 with the fix. The three title typo cases (creat index, delte index, refesh index) fail on the commit before the title lift. The remaining failure is the one that also fails on main.

Out of scope: Four typo queries still miss and sit in the report list: serch ties scroll with search because route keys are not fuzzed, clustr settings leads with indices-get-settings through the exact settings key, clustr stats ties cluster-state with cluster-stats, and pipline has no clear expected operation. The request cost of the extra clauses per query is unmeasured.

Risk: A word one edit from another title lifts that title too. get cluster stats still lists cluster-state first, because the lift adds 2.0 and a whole word beats a prefix by only 0.2. A weight does not fix it: delte index and creat index need the lift at about 1.0, and stats against state looks the same to the query as creat against create. The first result of no judged query changes.

🤖 Generated with Claude Code

reakaleek and others added 2 commits November 17, 2026 20:50
`clustr health` lists "Get the cluster health" first and "Get the cluster health status" third. `clustr` explains only as a field name, so all three health operations tie at 3.63 on the dev index. The case fails until the next commit.

`health cluster` joins the judged cases as a control. `clustr helth`, `creat index`, `serch knn` and `snapshot restor` join the report queries, so a run before and after the fix both list them.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
`clustr health` tied the three health operations at 3.63, because `clustr` explained only as a field name and `health` explained every operation equally. The title words cannot separate them, since all three titles carry both words.

Each plain word now also matches an operation id word within one edit, using the `AUTO:4,100` fuzziness and one-letter prefix the field names already use. The new `OperationWordTypo` weight of 1.5 sits between an exact id word (2.0) and the one-point roles, so an exact match on one operation still beats a typo on another. Both options share the `id` role name.

Measured on the dev index, `clustr health` leads with `cluster-health` at 4.63 against 3.63. The judged cases that passed before still pass, and no judged query changes its first result. Docs-wide search is untouched.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@reakaleek
reakaleek requested a review from a team as a code owner November 17, 2026 19:55
@reakaleek reakaleek added the bug label Nov 17, 2026
@reakaleek
reakaleek requested a review from akira28 November 17, 2026 19:55
Fifteen of the words people type most, such as `reindex`, `put mapping` and `snapshot create`, now lead with the operation they name. They pass without this fix and guard it against moving them.

Seven typo cases lead with the right operation: `cluser health`, `clustr state`, `snaphot restore`, `snapshto restore`, `reindx`, `bulck` and `indx refresh`. All but `indx refresh` fail on the commit before the fix. Six typo queries that still miss, such as `serch` and `refesh index`, join the report so a later change shows them.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

`delte index` listed Kibana operations whose ids carry both words, and `creat index` and `refesh index` listed the wrong operation first. The title fingerprint is one token, so a fuzzy match on it measures the edit distance across the whole title.

A typed text within one edit of a whole title now earns `TitleNamedTypo`, 2.0. The exact title is excluded, so an exact title keeps its score, and the weight sits below every endpoint key, so the lift only breaks ties. The index needs no change.

Measured on the dev index, `delte index` lists "Delete indices" first at 5.63 against 4.58, `creat index` at 6.13 against 5.08 and `refesh index` at 5.63 against 3.70. A word one edit from another title lifts that title too: `get cluster stats` lists `cluster-state` 2.0 above `cluster-stats`, where the two tied before.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
reakaleek and others added 3 commits November 17, 2026 21:15
The field names, the operation id words and the title each built the same fuzzy match by hand, so the one-edit rule lived in three places. `SearchQueryBuilder.FuzzyWordMatch` now owns the fuzziness and the fixed first letter, and `WordFuzziness` is private again.

The title lift is one `dis_max` of the exact and the typo match. That drops the `must_not` and the second run of the exact title on every request. A word shorter than four letters allows no edit, so it skips the typo option. The weights comment loses its measured scores, and one test holds the order of the exact and typo weights.

The report over 127 queries and the 152 relevance cases are unchanged on the dev index.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…r word

`stats` stems to `stat`, and the operation word role is a prefix match, so `stat` also began `state`. `cluster stats` tied `cluster-stats` with `cluster-state` at 11.63 and `clustr stats` listed them in either order.

The role now has an exact option at 2.0, a prefix option at 1.8 and the typo option at 1.5, all under one role name. Exact words keep their scores. A word that only begins another word loses 0.2, which changed four report scores and no first result.

`cluster stats` and `clustr stats` join the judged cases. `get cluster stats` still lists `cluster-state` first, because the title typo lift adds 2.0 to it, more than the 0.2 between a whole word and a prefix.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
It was one of the reported queries and only sat in the report list. The operation `snapshot restore` already leads for it, so the case passes and guards the typo match.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@reakaleek
reakaleek merged commit 06428b2 into main Nov 17, 2026
44 checks passed
@reakaleek
reakaleek deleted the fix-api-search-title-typo-35748668 branch November 17, 2026 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant