Skip to content

Commit 3b73de9

Browse files
authored
Fix(WEB-9483): Index HTTP Method + Path (GET /<path>) for API Search (#37784)
* feat(search): index API endpoint REST paths in content field Append the HTTP method and REST path to each API endpoint's search content so users can find endpoints by typing the path. Capture the method and path in api-pages-full-index.json and pass them to the per-endpoint indexer. * docs(search): comment API endpoint path/method capture * chore(search): revert API path indexing to baseline Remove the endpoint path/method indexing changes so this branch builds the master baseline search.json for diffing. To be re-added later. * fix(search): dedupe v1/v2 API records by anchorized summary Compare anchorized summaries in the v1/v2 disambiguation so endpoints whose translated summaries differ only by punctuation (e.g. trailing period) still get a unique -v1/-v2 anchor instead of colliding on one objectID and churning on every sync. * [empty] trigger build to test updated api * [test] tweak bits_chat overview wording to verify single-record sync diff * Revert [test] bits_chat wording change * Re-add API path/method indexing as a commented, inert toggle Forward $endpoint_path/$method into api-page-index.json and add a commented-out append to the content field. Disabled by default (uncomment one line to enable); output is unchanged from baseline. * Enable API endpoint path/method indexing in content field Append "METHOD /path" to each API endpoint record's content so endpoint REST paths are searchable. Appended at the end to keep it out of the start of the auto-embedded content. * Trim stale/low-value comments on API path indexing
1 parent 2d8c8fc commit 3b73de9

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

layouts/partials/algolia/api-page-index.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
{{ $lang := .lang }}
66
{{ $api_version := .api_version }} {{/* "v1" or "v2" */}}
77
{{ $endpoint_data := .endpoint_data }}
8+
{{ $endpoint_path := .endpoint_path }}
9+
{{ $method := .method }}
810
{{ $api_v1_translate_actions := .api_v1_translate_actions }}
911
{{ $api_v2_translate_actions := .api_v2_translate_actions }}
1012

@@ -20,13 +22,17 @@
2022
{{ $action_data := index $translate_actions_datafile $operationId }}
2123
{{ $section_header := $action_data.summary }}
2224
{{ $section_content := $action_data.description }}
25+
26+
{{/* Append "METHOD /path" so the endpoint's REST path is searchable. Kept at the end to stay out of the embedding's truncated input. */}}
27+
{{ $section_content = printf "%s\n\n%s %s" ($section_content | default "") (upper $method) $endpoint_path | strings.TrimSpace }}
28+
2329
{{ $endpoint_slug := $section_header | anchorize }}
2430
{{ $full_url := print $permalink $endpoint_slug "/" }}
2531
{{ $relpermalink = print $relpermalink $endpoint_slug "/" }}
2632

2733
{{/* When the same operationId+summary exists in both v1 and v2, both versions share one endpoint page with version tabs. Disambiguate the records by linking to the tab anchor. */}}
2834
{{ $other_action := cond (eq $api_version "v1") (index $api_v2_translate_actions $operationId) (index $api_v1_translate_actions $operationId) }}
29-
{{ if and (ne $other_action nil) (eq $other_action.summary $section_header) }}
35+
{{ if and (ne $other_action nil) (eq ($other_action.summary | anchorize) ($section_header | anchorize)) }}
3036
{{ $tab_anchor := (print $section_header "-" $api_version) | anchorize }}
3137
{{ $full_url = print $full_url "#" $tab_anchor }}
3238
{{ $relpermalink = print $relpermalink "#" $tab_anchor }}

layouts/partials/algolia/api-pages-full-index.json

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232

3333
{{/* Get all v1 api actions for this page by matching title with spec data's tag property */}}
3434
{{ range $endpoint_path, $endpoint_data := $api_v1_data.paths }}
35-
{{ range $endpoint_data }}
35+
{{ range $method, $action := $endpoint_data }}
3636
{{ $tags := slice }}
37-
{{ if isset . "tags" }}
38-
{{ $tags = .tags }}
37+
{{ if isset $action "tags" }}
38+
{{ $tags = $action.tags }}
3939
{{ end }}
4040

4141
{{ if in $tags $title }}
@@ -47,7 +47,9 @@
4747
"title" $title
4848
"lang" $lang
4949
"api_version" "v1"
50-
"endpoint_data" .
50+
"endpoint_data" $action
51+
"endpoint_path" $endpoint_path
52+
"method" $method
5153
"api_v1_translate_actions" $api_v1_translate_actions
5254
"api_v2_translate_actions" $api_v2_translate_actions
5355
)
@@ -60,10 +62,10 @@
6062

6163
{{/* Get all v2 api actions for this page by matching title with spec data's tag property */}}
6264
{{ range $endpoint_path, $endpoint_data := $api_v2_data.paths }}
63-
{{ range $endpoint_data }}
65+
{{ range $method, $action := $endpoint_data }}
6466
{{ $tags := slice }}
65-
{{ if isset . "tags" }}
66-
{{ $tags = .tags }}
67+
{{ if isset $action "tags" }}
68+
{{ $tags = $action.tags }}
6769
{{ end }}
6870

6971
{{ if in $tags $title }}
@@ -75,7 +77,9 @@
7577
"title" $title
7678
"lang" $lang
7779
"api_version" "v2"
78-
"endpoint_data" .
80+
"endpoint_data" $action
81+
"endpoint_path" $endpoint_path
82+
"method" $method
7983
"api_v1_translate_actions" $api_v1_translate_actions
8084
"api_v2_translate_actions" $api_v2_translate_actions
8185
)

0 commit comments

Comments
 (0)