Skip to content

Fix Algolia search ranking, record extraction, and modal breadth - #160

Merged
davidalucas merged 4 commits into
mainfrom
159-algolia-search-ranking
Nov 28, 2026
Merged

davidalucas merged 4 commits into
mainfrom
159-algolia-search-ranking

Conversation

@davidalucas

@davidalucas davidalucas commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes the Algolia DocSearch crawler extraction, ranking configuration, and navbar modal query parameters so MP Command Catalog entries, current API method pages, and product guides rank ahead of API Release History revisions and sub-section records.

Root Causes Addressed

  • Inverted weight.level: Custom API records used level: 1 for lvl1 pages and level: 2 for lvl2 sub-sections and Release History revisions under desc(weight.level), ranking Release History and sub-sections above current method and guide pages.
  • DOM-order weight.position on MP Catalog pages: Catalog commands used 0-based page heading order (0..58), so only the single position: 0 command per group page (e.g., Construct a Vector Group - Group to Group Compare) tied with position: 0 Release History records, burying Construct a Point in Working Coordinates (position: 1) and Construct a Point at line MidPoint (position: 5).
  • search_terms flattening attribute ranking & missing code identifiers: search_terms at searchableAttributes[0] bypassed heading hierarchy across sub-sections and missed actual differing code identifiers (including ConstructPointInWorkingCoordinates, .NET *Async methods, nested C# Task<...> returns, and TypeScript export declare function declarations).
  • Redundant API method sub-sections & attributeForDistinct: 'url': 8,020 current method pages emitted 28,110 records (including 8,020 copies of group-level Execution Notes boilerplate and "MP Catalog · gRPC Contract" lvl1 snippets), while attributeForDistinct: 'url' prevented page-level deduplication on guides and multi-revision history pages.
  • filters before attribute in ranking and modal saturation on API routes: Contextual API optionalFilters caused body-text mentions inside /api/<family>/... to outrank exact-title product guides (install, readiness, control center), and ungrouped family/release boosts could fill all modal candidates with one API family or shared client release versions (0.4.0).
  • Glued HTML text, .api-code-bar noise, and premature character truncation: Adjacent cells/blocks concatenated without spaces (FieldNameType, InputPoint Name, C#public Task), .api-code-bar labels polluted "C#" searches with thousands of .NET signatures, and fixed character slicing dropped searchable parameter notes well below 10 KB while risking oversize multibyte records.

Key Changes

  • search/algolia-crawler.cjs:
    • Added dedicated title, distinct_key, and family-scoped api_family_release fields; set searchableAttributes[0] to 'title,search_terms', attributeForDistinct to 'distinct_key', and quoted 'YOUR_INDEX_NAME' in initialIndexSettings so spaced index names parse cleanly when substituted.
    • Added 'api_family_release' to attributesForFaceting.
    • Established explicit descending weight.pageRank / weight.level tiers (Product Guides > Current MP Catalog & API Guides > Current API Methods [equal across SA 2024 and SA 2026] > non-current catalog dispositions > Release History) with title-length tie-breaking (weight.position).
    • Emits one clean signature-first lvl1 record per current API method page (plus a deduplicated #first-call-walkthrough record where present), uses language-scoped code-identifier extraction (covering proto, csharp nested generics, python def, and TypeScript export declare function / interface members without Python body false positives), strips .api-code-bar, uses block-aware text extraction (nodeText), and trims strictly against a 9,500-byte UTF-8 serialized JSON budget (fitRecord) while ordering gRPC field tables and notes ahead of repeated proto message definitions.
    • Moved filters after exact in ranking and added separatorsToIndex: '#'; kept hosted Algolia editor compatibility (new Crawler({ first, no ?. or ??).
  • src/components/ApiReference/context.ts & src/theme/SearchBar/index.tsx:
    • Updated searchFilters() to pair active API boosts with 'docusaurus_tag:docs-catalog-current' using Algolia OR sub-arrays, boost current release tag(s) on current and family/history routes so Release History does not crowd out sibling APIs, and scope earlier-release boosts via api_family_release:<family>-<release>.
    • Increased navbar modal hitsPerPage to 40 and maxResultsPerGroup to 6.
  • search/crawler.test.cjs, tests/api-reference.test.cjs, & README.md:
    • Added regression tests covering hosted-parser compatibility and spaced YOUR_INDEX_NAME substitution, ranking tiers, non-DOM-order catalog weights, language-scoped identifier extraction (setSaWindowState, ConstructBSplinesFromSurfacesAsync, Python body noise), UTF-8 byte-budget preservation (Direct CAD Access surface_normals_mode / "MP qualifier: 1 or 2." and BMP + emoji surrogate-pair cutoffs), MP Value Types, distinct_key, and "construct a" modal breadth across /, current SA 2026 gRPC, history, earlier server (0.7.0), and earlier shared client (0.4.0) routes.
    • Documented the hosted Algolia Dashboard index-setting updates (including api_family_release), expected ~40% record-count reduction safety-check notice, and updated the onboarding deployment workflow reference to deploy-workers.yml.

Validation

  • Node.js v24.22.3: npm run typecheck, search-enabled npm run build, npm run check:search (14/14 passed), npm run check:seo (48/48 passed), and git diff --check.
  • Full-sitemap local Algolia ranking simulation across all 13,141 built sitemap pages confirmed 24,436 total records (0 oversized, 0 duplicate IDs) and verified "construct a", "construct a point", "ConstructPointInWorkingCoordinates", "ConstructPointInWorkingCoordinatesAsync", "setSaWindowState", "ConstructBSplinesFromSurfacesAsync", "surface_normals_mode", "MP qualifier: 1 or 2", "GetWorkingDirectory", "install", "readiness", "control center", "C#", "Value Types", "PointName", "ConnectToSpatialAnalyzer", "SA 2024", "Run Crib Sheet", and "0.7.0 Angle Between Line and Plane" across homepage, current SA 2026/2024, family/history, earlier server (0.7.0), and earlier client (0.4.0) routes.

Post-Merge Hosted Algolia Rollout

After merge and deployment to briosa.dev:

  1. Apply the updated search/algolia-crawler.cjs in the Algolia Crawler editor (keeping hosted credentials, index name, schedule, and safety checks).
  2. Update the existing Briosa Documentation Website index settings in the Algolia Dashboard:
    • searchableAttributes: ["title,search_terms", "unordered(hierarchy.lvl1)", "unordered(hierarchy.lvl2)", "unordered(hierarchy.lvl3)", "unordered(hierarchy.lvl4)", "unordered(hierarchy.lvl5)", "unordered(hierarchy.lvl6)", "unordered(hierarchy.lvl0)", "content"]
    • ranking: ["words", "typo", "attribute", "proximity", "exact", "filters", "custom"]
    • attributeForDistinct: "distinct_key"
    • camelCaseAttributes: ["hierarchy", "content", "title"]
    • separatorsToIndex: "#"
    • attributesForFaceting: ["type", "lang", "language", "version", "docusaurus_tag", "api_family", "api_release", "api_family_release", "sa_target"]
  3. Trigger a full recrawl (expect total records to drop from ~40.6k to ~24.4k; approve or temporarily raise maxLostRecordsPercentage for this one-time drop, then restore it).

Closes #159

Fixes inverted weight.level rankings, DOM-order weight.position bias on MP Catalog pages, redundant API method sub-section records, glued HTML text, missing API code identifiers, and filters-before-attribute ranking so MP Catalog entries, current API method pages, and product guides rank above Release History revisions.

Closes #159
@davidalucas
davidalucas merged commit 22e1713 into main Nov 28, 2026
1 check passed
@davidalucas
davidalucas deleted the 159-algolia-search-ranking branch November 28, 2026 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix Algolia search ranking, record extraction, and result relevance

1 participant