Skip to content

List one field row per page section in API search results - #4820

Merged
reakaleek merged 1 commit into
mainfrom
balance-api-search-sectio-1f044fca
Nov 11, 2026
Merged

reakaleek merged 1 commit into
mainfrom
balance-api-search-sectio-1f044fca

Conversation

@reakaleek

Copy link
Copy Markdown
Member

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 listed metric.size from the request body three times and never showed data.legend.size from the response body. The dev index holds many cases like this. For query, 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

SearchResultProcessor gives 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

dotnet test --project tests/Elastic.Documentation.Api.Tests
# ProcessHit_SameNameRepeatedInTheRequest_StillListsTheResponseRow
# ProcessHit_MoreSectionsThanRows_ListsEverySection

The query snapshot changes only move size from 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" is data.legend.size (response body).
  • GET /_search size. "Run a search" lists size (query), collapse.inner_hits.size (request body) and profile.request.source.size (response body).
  • run a search field. The third row is hits.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 shows typed_keys, and an exact type row 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

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]>
@reakaleek
reakaleek requested a review from a team as a code owner November 11, 2026 14:52
@reakaleek
reakaleek requested a review from Mpdreamz November 11, 2026 14:52
@github-actions

Copy link
Copy Markdown
Contributor

@reakaleek
reakaleek merged commit e81b113 into main Nov 11, 2026
48 checks passed
@reakaleek
reakaleek deleted the balance-api-search-sectio-1f044fca branch November 11, 2026 15:11
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