@@ -34,51 +34,43 @@ jobs:
3434 # regression (which happened with #22861 dropping the index from
3535 # ~12k to 48 records) into a loud CI failure.
3636 MIN_HITS : " 5000"
37+ TYPESENSE_API_KEY : ${{ secrets.TYPESENSE_API_KEY }}
38+ TYPESENSE_HOST : ${{ secrets.TYPESENSE_HOST }}
3739 run : |
3840 set -euo pipefail
3941
40- # Derive the version-specific docusaurus_tag values from the docs version
41- # configs and append them to the api-nr start_url's docusaurus_tag array.
42- # Each plugin instance produces a tag of the form `docs-${pluginId}-${versionName}`.
43- # The unversioned tags (participate, root, default) are already in the static
44- # config; this step adds entries for `developer` and `network` which bump on
45- # release. Without this, the api-nr records would lose contextual search
46- # visibility every time mainnet/testnet versions change.
47- extra_tags=$(jq -nc \
48- --slurpfile dev docs/developer_version_config.json \
49- --slurpfile net docs/network_version_config.json \
50- '[
51- ("docs-developer-" + ($dev[0].mainnet // "")),
52- ("docs-developer-" + ($dev[0].testnet // "")),
53- ("docs-network-" + ($net[0].mainnet // "")),
54- ("docs-network-" + ($net[0].testnet // ""))
55- ] | map(select(. != "docs-developer-" and . != "docs-network-")) | unique')
56- echo "Derived docusaurus_tag values: $extra_tags"
57-
58- config_json=$(jq -c --argjson extra "$extra_tags" '
59- .start_urls |= map(
60- if .selectors_key == "api-nr"
61- then .extra_attributes.docusaurus_tag = ((.extra_attributes.docusaurus_tag // []) + $extra | unique)
62- else .
63- end
64- )
65- ' docs/typesense.config.json)
66-
6742 docker run \
68- -e "TYPESENSE_API_KEY=${{ secrets. TYPESENSE_API_KEY }} " \
69- -e "TYPESENSE_HOST=${{ secrets. TYPESENSE_HOST }} " \
43+ -e "TYPESENSE_API_KEY=$TYPESENSE_API_KEY" \
44+ -e "TYPESENSE_HOST=$TYPESENSE_HOST" \
7045 -e "TYPESENSE_PORT=443" \
7146 -e "TYPESENSE_PROTOCOL=https" \
72- -e "CONFIG=$config_json " \
47+ -e "CONFIG=$(cat docs/typesense.config.json) " \
7348 typesense/docsearch-scraper:0.11.0 2>&1 | tee scraper.log
7449
7550 nb_hits=$(grep -oE 'Nb hits: *[0-9]+' scraper.log | tail -1 | grep -oE '[0-9]+' || true)
7651 if [ -z "$nb_hits" ]; then
77- echo "::error::Could not parse 'Nb hits' from scraper output — assuming index is broken."
52+ echo "::error::Could not parse 'Nb hits' from scraper output, assuming index is broken."
7853 exit 1
7954 fi
8055 echo "Indexed $nb_hits records (threshold: $MIN_HITS)"
8156 if [ "$nb_hits" -lt "$MIN_HITS" ]; then
8257 echo "::error::Indexed only $nb_hits records (expected at least $MIN_HITS). Search index is likely broken."
8358 exit 1
8459 fi
60+
61+ # Log how many api-nr records are visible in the live index. The
62+ # docusaurus theme always prepends `default` to its contextual
63+ # docusaurus_tag filter, and no docusaurus page is stamped with
64+ # `default` (each carries its plugin-context tag instead), so this
65+ # facet count is effectively the count of indexed api-nr records.
66+ # Informational only: the count varies with aztec-nr content size.
67+ api_hits=$(curl -fsS \
68+ "https://$TYPESENSE_HOST/collections/aztec-docs/documents/search" \
69+ -H "X-TYPESENSE-API-KEY: $TYPESENSE_API_KEY" \
70+ -G \
71+ --data-urlencode "q=*" \
72+ --data-urlencode "query_by=hierarchy.lvl0" \
73+ --data-urlencode "filter_by=docusaurus_tag:=[default]&&language:=en" \
74+ --data-urlencode "per_page=1" \
75+ | jq -r '.found')
76+ echo "api-nr records visible under docusaurus_tag:=[default]: $api_hits"
0 commit comments