Route search by framework and version named in the query#392
Conversation
Search results are filtered to the framework/version of the page the user is on. When the user names one explicitly in the query, that should win - so "barcode capture ios" from a web page returns iOS results. - Framework (client-side, transformItems): a framework typed in the query (ios, android, flutter, web, react native, capacitor, cordova, titanium, .net ios/android) overrides the page framework; two named frameworks return both. Nothing typed keeps the page framework. On a framework-less page (home, /hosted/, concept pages) guides fall back to the most-used framework (web) rather than every framework's guide, while framework- agnostic pages (/hosted/, /id-documents/) stay findable. - Version (backend, search interceptor): a version named in the query (version 6, v6, 6.x, 6.28, sdk 6) rewrites the contextual docusaurus_tag filter to the newest tag on that major line - 6 to docs-default-6.28.11, 7 to docs-default-7.6.14, 8 to current. The typed framework word is left in the query; removeWordsIfNoResults drops it when it does not match page text, so ranking is unaffected. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Addresses review feedback: the search widget's "major version typed in a query -> docusaurus_tag" map previously hardcoded patch versions (6.28.11, 7.6.14) and the current mapping, which could drift from the real versions. Now docusaurus.config.ts holds a single docsVersions source of truth (the preset consumes it directly), and buildVersionTagByMajor derives the map from it - each frozen version -> docs-default-<version>, current -> docs-default-current with its major from label. The result is exposed via customFields.versionTagByMajor and read in SearchBar, so a version bump through scripts/update-version.py flows in automatically with nothing to keep in sync. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
51e606d to
4ac7c0c
Compare
lucatorella
left a comment
There was a problem hiding this comment.
Automated code review (Claude Code, high effort). 6 findings below — 5 inline, plus one that anchors to unchanged code outside this diff's hunks so it's noted here instead:
[correctness, CONFIRMED] ResultsFooter's fallback note can contradict the actual results shown (src/theme/SearchBar/index.js, ResultsFooter / showApiFallbackNote, around line 85 on main).
On a framework-less page, currentFramework is "". A user searches "barcode capture ios"; transformItems filters API hits to iOS (via apiFwTargets = queriedFrameworks), but showApiFallbackNote = !currentFramework && hasApiResults is still true, so the footer renders "Showing the web API reference - open a specific SDK's docs for another platform" even though the results shown are iOS, not web.
Overall theme of the inline findings: the new version/framework query-inference logic false-positives on ordinary query text and silently narrows or rewrites the search facets, in several cases contradicting comments in the same file promising broader/framework-agnostic results.
Addresses code-review findings on the query-inference logic:
- Footer note: only show the "web API reference" fallback note when no
framework was typed (compute hasQueriedFramework from state.query), so it
can't contradict framework-filtered results.
- Version tag rewrite: swap only the versioned docs tag (docusaurus_tag:docs-*),
leaving docusaurus_tag:default and the contextual OR intact so
non-versioned / framework-agnostic pages still match when a version is typed.
- Version detection: drop the bare dotted-number pattern; only an explicit
marker (version/ver/v/sdk N) triggers a rewrite, avoiding false positives on
incidental tokens like "6.5" or "7.1".
- Framework-agnostic pages (/hosted/, /id-documents/, concept pages) stay
findable in every branch - typed framework, page framework, and
framework-less - instead of being dropped; only /sdks/ guides are narrowed.
- "web" query token requires stronger context (web sdk, on/for/in/using web)
so ordinary queries ("web view", "web socket") don't hijack routing.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
d8b7c40 to
aca6b32
Compare
|
Pushed aca6b32. Updated per the review:
|
lucatorella
left a comment
There was a problem hiding this comment.
Approving after review — inline findings addressed in commit aca6b32 ("Harden query-based framework/version routing from review feedback").
Search results are filtered to the framework/version of the page the user is on. When the user names one explicitly in the query, that should win - so "barcode capture ios" from a web page returns iOS results.
Framework: a framework typed in the query (ios, android, flutter, web, react native, capacitor, cordova, titanium, .net ios/android) overrides the page framework; two named frameworks return both. Nothing typed keeps the page framework. On a framework-less page (home, /hosted/, concept pages) guides fall back to the most-used framework (web) rather than every framework's guide, while framework-agnostic pages (/hosted/, /id-documents/) stay findable.
Version: a version named in the query (version 6, v6, 6.x, 6.28, sdk 6) rewrites the contextual docusaurus_tag filter to the newest tag on that major line - 6 to docs-default-6.28.11, 7 to docs-default-7.6.14, 8 to current.
The typed framework word is left in the query; removeWordsIfNoResults drops it when it does not match page text, so ranking is unaffected.