Skip to content

Make API group, type and topic pages searchable - #5043

Merged
akira28 merged 5 commits into
feature/api-export-literal-textfrom
feature/api-searchable-pages
Nov 25, 2026
Merged

akira28 merged 5 commits into
feature/api-export-literal-textfrom
feature/api-searchable-pages

Conversation

@akira28

@akira28 akira28 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

API group, type, topic, authentication and Markdown pages now appear in docs search and the API search box. A search for Snapshot and restore or authentication finds the page itself, not only its operations.

Closes elastic/docs-eng-team#1230

Affects: Search, API reference, MCP

Prompt summary: The author asks for the cleanest way to make non-operation API pages searchable (elastic/docs-eng-team#1230). This PR replaces #5036, whose review rounds kept patching how it guessed text from an ambiguous export.

Stack: 2 of 2, on top of #5042, which makes the export unambiguous.

Why

Since #4983, every non-operation API page has a search document only so the sitemap can date it. Those documents are hidden: true and api.sitemap_only: true, with an empty body. Search, navigation search, the change feed and the MCP tools never return them. The page that answers a reader's query stays invisible.

What

One searchable document per page

OpenApiGenerator.PageContentsAsync gives search text to every page that is not an operation, not the landing page and not excluded from indexing. The search text is the page's front-matter title and description, already plain text since #5042, plus its Markdown export as readers get it. OpenApiDocumentExporter.DatedByPage turns that into a visible api.page document with API > <Product> API parents and the product. Each page still has one document with the same content hash, so the sitemap's lastmod dates do not move. Identical pages collapse across version trees as operations do. ApiTreeCollapse identifies a page by its content hash and its path relative to the tree root, so pages at different slugs stay apart.

Other pages stay date-only

Skipped operations, such as unreleased ones or aliases of a collapsed operation, and excluded pages such as Servers keep their hidden api.sitemap_only document. The sitemap_only filters stay, so the live index behaves correctly before and after the next indexing run.

The indexer reads pages like operations

ElasticsearchMarkdownExporter.ApplyApiMarkdown parses an API document's Markdown once. It writes the plain-text body for every API document, and on a page document it also writes the section headings. No search-specific plain-text code is added.

Search, MCP and result rows

The MCP operation tools (ApiGateway.OperationFilter) exclude api.page documents, as they exclude landing pages. ApiLookupQueryBuilder keeps landing and other pages out unless every typed word is in their title, so a type page that lists every property does not match most property queries. Navigation search returns page, and a row for one of these pages reads "Go to page".

Risk: the index mapping gains api.page. The next indexing run writes about 570 more documents with a real body, and AI enrichment and semantic inference run on them.

Out of scope: SearchRelevanceTests were not run against the dev index. Run them before and after to measure how group and type pages compete with operations on short queries.

Review rules

These settle trade-offs that review findings can pull either way. A finding that breaks one is a bug; one that asks to trade against it is out of scope.

  • A page's identity across version trees is its content hash plus its path relative to the tree root. That is the hash the sitemap dates the page by, so a shared search document and its lastmod always agree. Versions that differ only in whitespace share one document.
  • Search reads what the page shows, through Escape literal names in the API Markdown export #5042's plain-text rule, and gets its title and description from the export's front matter.

Verify

dotnet test --project tests/Elastic.ApiExplorer.Tests --treenode-filter "/*/*/OpenApiGeneratorCatalogSplitTests/*"
# ExportDocuments_PagesWithoutAnOperation_AreSearchableUnlessExcluded — group, authentication and servers pages
dotnet test --project tests/Elastic.Markdown.Tests --treenode-filter "/*/*/OpenApiHeadingsTests/*"
# ApplyApiMarkdown_PageDocument_ReadsItsSectionsAndPlainTextFromTheExport
./build.sh unit-test
mise run site:test

Check on the preview

The preview has no search backend (its /docs/_api returns 404), so the search box cannot show these pages there. Each page's search document is built from its Markdown export: the front matter gives the title and description, and the body becomes the indexed text and section headings. These exports show what each page contributes to the index.

🤖 Generated with Claude Code

Comment on lines +102 to +104
Title = search.Title,
SearchTitle = search.Title,
Description = search.Description,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Severity: P3 (Low)

Preserve literal angle-bracket text when returning these new search hits. The added HTTP <code> responses fixture is indexed correctly, but the navigation search treats the raw <code> as markup and displays HTTP responses. Escape the text before adding highlight markup so the result matches the page title.

Generated by Libra. React with 👍 or 👎 to give feedback on this comment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed by #5038, now merged on main, which this stack is rebased on. The search result processor encodes the title and description around its <mark> tags, so the row shows HTTP <code> responses.

@github-actions

Copy link
Copy Markdown
Contributor

@akira28
akira28 force-pushed the feature/api-searchable-pages branch from ad94292 to 5e774fc Compare November 24, 2026 18:40
@akira28
akira28 force-pushed the feature/api-searchable-pages branch from 5e774fc to c007ee2 Compare November 24, 2026 19:07
akira28 and others added 4 commits November 24, 2026 20:19
Pages that are not operations had hidden, empty `sitemap_only` documents, so
search never found them. Each such page now gets one visible `api.page`
document: its front-matter title and description, and its Markdown export,
which the indexer reads like an operation's body and takes section headings
from. Skipped operations and excluded pages such as Servers keep their
sitemap-only documents. The MCP operation tools and the API lookup keep these
pages out unless every typed word is in their title.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A page's search body is its export as readers get it, so a URL in prose no
longer shows as `{api-root}`. Version trees still collapse a page: its body
counts through its content hash, which reads links relative to the tree. The
collapse fingerprint also compares the path relative to the tree root, so
identical pages at different slugs stay separate documents.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The collapse fingerprint compares a page body with its links read relative to
its tree, instead of through the whitespace-normalized content hash. Two
trees that lay a page out differently, such as a heading on its own line
against the same text inline, keep their own search documents.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The collapse fingerprint takes a page body through its content hash again,
the hash the sitemap dates the page by, so a page that shares a search
document across versions also shares its `lastmod`. The path relative to
the tree root still keeps pages at different slugs apart. Two versions that
differ only in whitespace share one document; their indexed text is the same.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@akira28
akira28 force-pushed the feature/api-searchable-pages branch from c007ee2 to 4e4e970 Compare November 24, 2026 19:21
{
Path = "",
Path = doc.Path.StartsWith(root, StringComparison.Ordinal) ? doc.Path[root.Length..] : doc.Path,
Body = doc.Api.Page ? "" : doc.Body,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Severity: P3 (Low)

The sitemap hash is not enough to decide whether two versions can share a search document. It collapses all whitespace, so Authentication\n--- (a section heading) and Authentication\n\n--- (a paragraph followed by a rule) hash identically. When that is the only difference between versions of a topic, the indexer gets only the default version’s body and uses its headings and summary for both versions. Keep the sitemap hash for dating, but compare the tree-relative Markdown separately when collapsing search documents.

Generated by Libra. React with 👍 or 👎 to give feedback on this comment.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it also possible to search of a specific property in a Type ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add in the next pr

@akira28
akira28 merged commit eea8cea into main Nov 25, 2026
44 checks passed
@akira28
akira28 deleted the feature/api-searchable-pages branch November 25, 2026 09:48
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.

2 participants