Skip to content

Find API fields by the words of their name - #4750

Merged
reakaleek merged 4 commits into
mainfrom
fix-api-docs-search-under-018cb6e3
Nov 5, 2026
Merged

reakaleek merged 4 commits into
mainfrom
fix-api-docs-search-under-018cb6e3

Conversation

@reakaleek

Copy link
Copy Markdown
Member

API search now finds a field from the words of its name. The words can be typed in any order, without underscores, and with one typo. unrated docs, docs unrated and unreated docs all list rank-eval with its unrated_docs row, and _uri finds last_uri.

Affects: Search, API reference

Prompt summary: While testing API search, unrated_docs found the field but unrated docs found nothing. A reader needs to find an attribute without knowing exactly how it is named: without underscores, and not in the exact wording or order.

Why

The API lookup requires every typed word to match some role on an operation. A field matched only when its keyword name started with the typed word, so docs never met unrated_docs and _uri never met last_uri. A typo matched nothing at all. The index held no per-word form of a field name, because path_words splits only at dots.

What

The words of each field name in the index

Each indexed field row now carries name_words, the words of its name split at _, -, . and camelCase. unrated_docs gives unrated docs and indexPattern gives index pattern. The splitter moved from ApiSearchWords into the search contract as ApiPropertyPath.IdentifierWords, so operation ids and field names split the same way.

A word option on the field role

BuildPropertyNameOptions adds a third option next to the exact and prefix name matches. The typed word is split the same way, so _uri looks for the word uri. Each word matches in full or with one typo from four letters (AUTO:4,100). It also matches as a prefix from three letters, or as the last word of a typed compound such as unrated_do. A one- or two-letter word matches a whole word only, so scroll id meets scroll_id while s and cl keep their results.

Ranking

A word match scores FieldWord (0.5), below a name prefix (0.6) and above a listed child (0.4). A typed identifier still beats its own words. A row that also names another typed word gets FieldSeveralWords, which brings it to a full name match (1.0). This bonus sits inside each word's nested query, so it also sorts that row first among the operation's matched fields.

Risk: the new field changes the api mapping of the docs indices and of the website search index, which shares the contract. The next indexing run rolls each one over to a new dated index, as the dev run on this branch did. A code revert does not undo the rollover.

Out of scope: the docs-wide search still looks up fields only when a word holds _ or ., and typos in titles, ids and descriptions are unchanged.

Verify

mise run test

To try it against Elasticsearch, index dev, build with the API explorer and serve a Debug build:

dotnet run --project src/tooling/docs-builder -- assembler index --environment dev --skip-private-repositories --no-ai-enrichment
FEATURE_ASSEMBLER_API_EXPLORER=true dotnet run --project src/tooling/docs-builder -- assembler build --environment dev --skip-private-repositories --no-assume-build
ENVIRONMENT=dev DOCS_BUILD_TYPE=assembler .artifacts/bin/docs-builder/debug/docs-builder assembler serve --port 4005

Then type these into the search box on /docs/api. unreated docs lists rank-eval with unrated_docs. _uri lists Get cluster subsystem info with http.clients[].last_uri. search knn, snapshot restore and retriever. keep the same top results as on main.

🤖 Generated with Claude Code

API search found `unrated_docs` only when the reader typed the identifier. `unrated docs`, `unreated docs` and `_uri` (for `last_uri`) found nothing. Each field now indexes the words of its name in `name_words`. The API lookup matches a typed word against them in full, as a prefix from three letters, or with one typo from four letters. A row that names more than one typed word scores as a name match, so it lists first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@reakaleek
reakaleek requested a review from a team as a code owner November 5, 2026 16:03
@reakaleek
reakaleek requested a review from Mpdreamz November 5, 2026 16:03
reakaleek and others added 2 commits November 5, 2026 17:10
The several-words lift matched every typed word with `minimum_should_match: 2`, so a typed compound next to another word, as in `unrated_docs rank`, met the threshold with its own two parts. Each word now lifts a row only by the words of the other typed words, which keeps a typed identifier above rows that only share its words.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The unit tests only snapshot the query. These relevance cases run it against an index and assert the operation and its field for `unrated docs`, `docs unrated`, `unreated docs` and `_uri`. Two more cases assert that the row naming every typed word lists first when other rows share one of them.

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

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@reakaleek
reakaleek merged commit 9afad83 into main Nov 5, 2026
36 checks passed
@reakaleek
reakaleek deleted the fix-api-docs-search-under-018cb6e3 branch November 5, 2026 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant