Repository navigation
List one field row per page section in API search results - #4820
Merged
Merged
Conversation
A field repeated in the request body filled all three rows, so the same field in the response or a query parameter never showed. Each section that matched now gets its best row first, and the remaining rows go by score. The docs-wide lookup fetches 20 inner hits, like the API lookup, so rows from other sections reach the result. 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/4820/ |
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.
An API search result now lists the best matching field from every section of the operation, so a field repeated in the request body no longer hides the same field in the response body or a query parameter.
Affects: Search, API reference
Prompt summary: Balance the field rows of an API search result across the operation page. When a field name matches, every section that has it (path, query, header, request body, response body) shows at least one row, instead of three rows from the request body.
Why
A search result lists at most three field rows, picked by score. When a name repeats in one section, all three rows come from that section. For
create visualization size, the "Create visualization" result listedmetric.sizefrom the request body three times and never showeddata.legend.sizefrom the response body. The dev index holds many cases like this. Forquery, 29 of 200 matching operations had only request rows in their first three, although the field also appears in the response.What
One row per section first
SearchResultProcessorgives each matched section its best row first. The remaining rows go to the next best matches by score, up to three. All rows keep score order. When four or five sections match, each one still gets a row, so three is a soft limit. A section that a parent row already covers with its expanded children gets no extra row.Enough rows to choose from
The docs-wide lookup asked Elasticsearch for only five field rows per operation, so five equal-score request rows could hide every other section before the selection ran. Both lookups now ask for 20 rows, so the two size constants merge into one. Autocomplete latency on the dev cluster did not change: the median was 139 ms before and 142 ms after, over 48 identifier queries each.
Verify
The query snapshot changes only move
sizefrom 5 to 20.To compare on a local assembler serve, open the API search box with
/and try these queries:create visualization size. The third row of "Create visualization" isdata.legend.size(response body).GET /_search size. "Run a search" listssize(query),collapse.inner_hits.size(request body) andprofile.request.source.size(response body).run a search field. The third row ishits.hits[]._nested.field(response body).Out of scope: A section's best row can be a weak prefix match. For
run multiple searches type, the query slot showstyped_keys, and an exacttyperow from the request body drops out. Counting a section only when it has an exact name match would fix that, in a separate change.🤖 Generated with Claude Code