Commit 8b76042
authored
fix(docs): use scalar docusaurus_tag "default" for api-nr records (#23097)
## Summary
Fourth in the series fixing search after #22861. After #23058 merged,
the production index still has **0 records under
`aztec-nr-api/mainnet/...`**. Confirmed by querying the live Typesense
collection directly
(`filter_by:url:=https://docs.aztec.network/aztec-nr-api/mainnet/*`
returns `found: 0`) and by inspecting the most recent scraper run logs.
## Root cause
The schema override added by #23058 doesn't take effect. Every api-nr
document import is rejected by Typesense with HTTP 400 `'Field
\`docusaurus_tag\` must be a string.'`, even though
`custom_settings.field_definitions` lists an explicit `{ \"name\":
\"docusaurus_tag\", \"type\": \"string*\" }` ahead of the wildcard
`.*_tag: string`. Per Typesense docs an explicit field should win over a
regex pattern field, but in practice the wildcard's `string` type
appears to be what's enforced. The CI guard from #23042
(`MIN_HITS=5000`) didn't trip because the ~12k non-api docs still
passed.
## Fix
The PR over-engineered the solution. Reading the docusaurus theme:
```ts
// docusaurus-theme-common/src/utils/searchUtils.ts
export const DEFAULT_SEARCH_TAG = 'default';
```
```ts
// docusaurus-theme-common/src/index.ts
const tags = [DEFAULT_SEARCH_TAG, ...docsTags];
return {locale: i18n.currentLocale, tags};
```
…the theme unconditionally prepends `'default'` to the `docusaurus_tag`
filter on every dropdown query, in every plugin context. So api-nr
records only need the single scalar value `\"default\"` to satisfy the
filter from anywhere on the docs site. No array, no schema surgery, no
version-specific tag derivation.
Three changes:
### 1. `docs/typesense.config.json`
Drop the `custom_settings.field_definitions` override entirely (the
scraper's default schema with `.*_tag: string` accepts scalar string
values cleanly), and collapse the api-nr
`extra_attributes.docusaurus_tag` to scalar `\"default\"`.
### 2. `.github/workflows/docs-typesense.yml` — remove jq mutation
The jq block that derived versioned tags is no longer needed. The
scraper now reads `docs/typesense.config.json` verbatim.
### 3. `.github/workflows/docs-typesense.yml` — log api-nr visibility
post-index
After the scraper completes its alias swap, curl the live `aztec-docs`
alias for `docusaurus_tag:=[default]&&language:=en` and log the count.
No existing docusaurus page carries the `\"default\"` tag (each is
stamped with its plugin-context tag, e.g. `docs-developer-v4.2.0`, from
the `<meta name=\"docsearch:docusaurus_tag\">` tag), so this count is
effectively the count of indexed api-nr records — and the filter mirrors
what the theme actually sends. Informational only; not gated by a
threshold.
## Behavior change
api-nr records will now appear in the search dropdown from every plugin
context (developer, network, root, participate) and every doc version
(mainnet, testnet, nightly), because they're stamped with the
always-prepended `\"default\"` tag rather than version-specific tags.
Today we only generate `aztec-nr-api/mainnet/`, so a user browsing
testnet developer docs would see mainnet aztec-nr API links in their
dropdown. Probably desirable (an aztec-nr API symbol is the same
regardless of which doc version you're reading), but a behavior change
vs the (non-functional) #23058 attempt.
## Caveat
api-nr visibility now depends on the docusaurus theme's
`DEFAULT_SEARCH_TAG = 'default'` invariant. If a future caller ever
issues a search query that doesn't include `'default'` in the tag list
(e.g. a custom search page bypassing `useContextualSearchFilters`),
api-nr records would silently disappear from that surface.
## Test plan
- [ ] Manually dispatch `Docs Scraper` workflow via `workflow_dispatch`
on this branch.
- [ ] Confirm the run logs `Indexed N records (threshold: 5000)` with N
>> 5000.
- [ ] Confirm the run logs `api-nr records visible under
docusaurus_tag:=[default]: M` with M well above zero (#23049 indexed
14,773 api-nr records before the schema rejection started silently
dropping them, so we expect a similar count).
- [ ] Confirm no `'Field \`docusaurus_tag\` must be a string.'` 400s in
the scraper output.
- [ ] After merge, search docs.aztec.network from the homepage,
/developers/, /network/, and /participate/ for an Aztec.nr identifier
(e.g. `ContractClassId`, `balance_set`, `compute_log_tag`,
`address_note`) and confirm API reference pages appear in the dropdown
in all four contexts.2 files changed
Lines changed: 24 additions & 106 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | 42 | | |
68 | | - | |
69 | | - | |
| 43 | + | |
| 44 | + | |
70 | 45 | | |
71 | 46 | | |
72 | | - | |
| 47 | + | |
73 | 48 | | |
74 | 49 | | |
75 | 50 | | |
76 | 51 | | |
77 | | - | |
| 52 | + | |
78 | 53 | | |
79 | 54 | | |
80 | 55 | | |
81 | 56 | | |
82 | 57 | | |
83 | 58 | | |
84 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
| 10 | + | |
15 | 11 | | |
16 | 12 | | |
17 | 13 | | |
| |||
63 | 59 | | |
64 | 60 | | |
65 | 61 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | 62 | | |
137 | 63 | | |
138 | 64 | | |
| |||
0 commit comments