Repository navigation
Find API fields by the words of their name - #4750
Merged
Merged
Conversation
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]>
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]>
Contributor
Docs preview (local build)Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4750/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 unratedandunreated docsall list rank-eval with itsunrated_docsrow, and_urifindslast_uri.Affects: Search, API reference
Prompt summary: While testing API search,
unrated_docsfound the field butunrated docsfound 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
docsnever metunrated_docsand_urinever metlast_uri. A typo matched nothing at all. The index held no per-word form of a field name, becausepath_wordssplits 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_docsgivesunrated docsandindexPatterngivesindex pattern. The splitter moved fromApiSearchWordsinto the search contract asApiPropertyPath.IdentifierWords, so operation ids and field names split the same way.A word option on the field role
BuildPropertyNameOptionsadds a third option next to the exact and prefix name matches. The typed word is split the same way, so_urilooks for the worduri. 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 asunrated_do. A one- or two-letter word matches a whole word only, soscroll idmeetsscroll_idwhilesandclkeep 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 getsFieldSeveralWords, 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
apimapping 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 testTo try it against Elasticsearch, index dev, build with the API explorer and serve a Debug build:
Then type these into the search box on
/docs/api.unreated docslists rank-eval withunrated_docs._urilists Get cluster subsystem info withhttp.clients[].last_uri.search knn,snapshot restoreandretriever.keep the same top results as onmain.🤖 Generated with Claude Code