Skip to content

Commit a7ccfb8

Browse files
authored
Remove general autocomplete feature (#56000)
1 parent c53f1b8 commit a7ccfb8

File tree

16 files changed

+14
-578
lines changed

16 files changed

+14
-578
lines changed

.github/workflows/index-autocomplete-search.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Index autocomplete search in Elasticsearch
22

3-
# **What it does**: Indexes autocomplete data (general and AI search) into Elasticsearch.
4-
# **Why we have it**: So we can power the APIs for autocomplete.
3+
# **What it does**: Indexes AI search autocomplete data into Elasticsearch.
4+
# **Why we have it**: So we can power the APIs for AI search autocomplete.
55
# **Who does it impact**: docs-engineering
66

77
on:
@@ -40,11 +40,6 @@ jobs:
4040
if: ${{ github.event_name == 'pull_request' }}
4141
run: curl --fail --retry-connrefused --retry 5 -I http://localhost:9200
4242

43-
- name: Run general auto-complete indexing
44-
env:
45-
ELASTICSEARCH_URL: ${{ github.event_name == 'pull_request' && 'http://localhost:9200' || secrets.ELASTICSEARCH_URL }}
46-
run: npm run index-general-autocomplete -- docs-internal-data
47-
4843
- name: Run AI search auto-complete indexing
4944
env:
5045
ELASTICSEARCH_URL: ${{ github.event_name == 'pull_request' && 'http://localhost:9200' || secrets.ELASTICSEARCH_URL }}

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@
4949
"general-search-scrape-server": "cross-env NODE_ENV=production PORT=4002 MINIMAL_RENDER=true CHANGELOG_DISABLED=true tsx src/frame/server.ts",
5050
"ghes-release-scrape-with-server": "cross-env GHES_RELEASE=1 start-server-and-test general-search-scrape-server 4002 general-search-scrape",
5151
"general-search-scrape-with-server": "cross-env NODE_OPTIONS='--max_old_space_size=8192' start-server-and-test general-search-scrape-server 4002 general-search-scrape",
52-
"index": "tsx src/search/scripts/index/index-cli autocomplete docs-internal-data",
5352
"index-ai-search-autocomplete": "tsx src/search/scripts/index/index-cli ai-search-autocomplete",
54-
"index-general-autocomplete": "tsx src/search/scripts/index/index-cli general-autocomplete",
5553
"index-general-search": "tsx src/search/scripts/index/index-cli general-search",
5654
"index-test-fixtures": "./src/search/scripts/index-test-fixtures.sh",
5755
"labeler": "tsx .github/actions/labeler/labeler.ts",

src/search/README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,15 @@ You can also query our search endpoint directly at:
2222

2323
## Types of search
2424

25-
Our backend currently supports 3 "types" of searching.
25+
Our backend currently supports 2 "types" of searching.
2626

2727
All searches accept a `query` param, e.g. `?query=how` and return results based on their type:
2828

2929
1. **general search**
3030
- Results: The pages of our sites that match the query, sorted by popularity
3131
- Example: Query = "clone" -> Results <URLs to Docs Page about cloning>
3232
- Endpoint: `/api/search/v1`
33-
2. **general autocomplete**
34-
- Results: Potential terms that can be autocompleted from the query based on previous user searches
35-
- Example: Query = "cl" -> A Result = "clone"
36-
- Endpoint: `/api/search/autocomplete/v1`
37-
3. **AI search autocomplete**
33+
2. **AI search autocomplete**
3834
- Results: Human-readable full-sentence questions that best match the query. Questions are based on previous searches and popular pages
3935
- Example: Query = "How do I clone" -> A Result = "How do I clone a repository?"
4036
- Endpoint: `/api/search/ai-search-autocomplete/v1`
@@ -66,7 +62,7 @@ The preferred way to build and sync the search indices is to do so via the [GitH
6662
### Actions workflow files
6763

6864
- [`.github/workflows/index-general-search.yml`](/.github/workflows/index-general-search.yml) - Populates search indices for **general search** using the `main` branch every four hours. Search indices are stored in an internal-only Elasticsearch instance. To run it manually, click "Run workflow" button in the Actions tab.
69-
- [`.github/workflows/index-autocomplete-search.yml`](/.github/workflows/index-general-search.yml) - Populates search indices for both **general autocomplete** and **AI search autocomplete** using data from an internal repo. Runs daily.
65+
- [`.github/workflows/index-autocomplete-search.yml`](/.github/workflows/index-general-search.yml) - Populates search indices for **AI search autocomplete** using data from an internal repo. Runs daily.
7066

7167
### Notable code files and directories
7268

src/search/lib/elasticsearch-indexes.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ export type SearchIndex = {
1515

1616
/* Elasticsearch uses indexes to group categories of data
1717
18-
We currently have 3 top-level categories of indexes:
18+
We currently have 2 top-level categories of indexes:
1919
1. General search: This is populated using data from all of our Docs pages
20-
2. General autocomplete: This is populated using analytics search history in docs-internal-data
21-
3. AI autocomplete: This is populated with human-readable questions using a GPT query in docs-internal-data
20+
2. AI autocomplete: This is populated with human-readable questions using a GPT query in docs-internal-data
2221
2322
This file is intended to be the source of truth for Docs Elasticsearch indexes.
2423
@@ -34,10 +33,6 @@ const indexes: SearchIndexes = {
3433
prefix,
3534
type: 'general-search',
3635
},
37-
generalAutocomplete: {
38-
prefix,
39-
type: 'general-autocomplete',
40-
},
4136
aiSearchAutocomplete: {
4237
prefix,
4338
type: 'ai-search-autocomplete',

src/search/lib/get-elasticsearch-results/general-autocomplete.ts

Lines changed: 0 additions & 123 deletions
This file was deleted.

src/search/lib/search-request-params/search-params-objects.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ import type { SearchRequestQueryParams } from '@/search/lib/search-request-param
1111

1212
// Entry to this file, returns the query parameters to expect based on the type of search request
1313
export function getSearchRequestParamsObject(type: SearchTypes): SearchRequestQueryParams[] {
14-
if (type === 'generalAutocomplete') {
15-
return AUTOCOMPLETE_PARAMS_OBJ
16-
} else if (type === 'aiSearchAutocomplete') {
14+
if (type === 'aiSearchAutocomplete') {
1715
return AI_SEARCH_AUTOCOMPLETE_PARAMS_OBJ
1816
}
1917
return GENERAL_SEARCH_PARAMS_OBJ
@@ -136,11 +134,6 @@ const AI_SEARCH_AUTOCOMPLETE_PARAMS_OBJ: SearchRequestQueryParams[] = [
136134
{ key: 'language', default_: 'en', validate: (language: string) => language === 'en' },
137135
]
138136

139-
const AUTOCOMPLETE_PARAMS_OBJ: SearchRequestQueryParams[] = [
140-
...SHARED_AUTOCOMPLETE_PARAMS_OBJ,
141-
{ key: 'language', default_: 'en', validate: (language: string) => language in languages },
142-
]
143-
144137
function toBoolean(value: any): boolean {
145138
return value === 'true' || value === '1'
146139
}

src/search/lib/search-request-params/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ export interface ComputedSearchQueryParamsMap {
3333
toplevel: string[]
3434
aggregate: string[]
3535
}
36-
generalAutocomplete: ComputedSearchQueryParams
3736
aiSearchAutocomplete: ComputedSearchQueryParams
3837
}
3938

src/search/middleware/search-routes.ts

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
setFastlySurrogateKey,
1414
SURROGATE_ENUMS,
1515
} from '@/frame/middleware/set-fastly-surrogate-key.js'
16-
import { getAutocompleteSearchResults } from '@/search/lib/get-elasticsearch-results/general-autocomplete'
1716
import { getAISearchAutocompleteResults } from '@/search/lib/get-elasticsearch-results/ai-search-autocomplete'
1817
import { getSearchFromRequestParams } from '@/search/lib/search-request-params/get-search-from-request-params'
1918
import { getGeneralSearchResults } from '@/search/lib/get-elasticsearch-results/general-search'
@@ -59,39 +58,6 @@ router.get(
5958
}),
6059
)
6160

62-
router.get(
63-
'/autocomplete/v1',
64-
catchMiddlewareError(async (req: Request, res: Response) => {
65-
const {
66-
indexName,
67-
validationErrors,
68-
searchParams: { query, size, debug },
69-
} = getSearchFromRequestParams(req, 'generalAutocomplete')
70-
if (validationErrors.length) {
71-
return res.status(400).json(validationErrors[0])
72-
}
73-
74-
const options = {
75-
indexName,
76-
query,
77-
size,
78-
debug,
79-
}
80-
try {
81-
const { meta, hits } = await getAutocompleteSearchResults(options)
82-
83-
if (process.env.NODE_ENV !== 'development') {
84-
searchCacheControl(res)
85-
setFastlySurrogateKey(res, SURROGATE_ENUMS.MANUAL)
86-
}
87-
88-
res.status(200).json({ meta, hits })
89-
} catch (error) {
90-
await handleGetSearchResultsError(req, res, error, options)
91-
}
92-
}),
93-
)
94-
9561
router.get(
9662
'/ai-search-autocomplete/v1',
9763
catchMiddlewareError(async (req: Request, res: Response) => {
@@ -161,10 +127,6 @@ router.get('/', (req: Request, res: Response) => {
161127
res.redirect(307, req.originalUrl.replace('/search', '/search/v1'))
162128
})
163129

164-
router.get('/autocomplete', (req: Request, res: Response) => {
165-
res.redirect(307, req.originalUrl.replace('/search/autocomplete', '/search/autocomplete/v1'))
166-
})
167-
168130
router.get('/ai-search-autocomplete', (req: Request, res: Response) => {
169131
res.redirect(
170132
307,

src/search/scripts/index-test-fixtures.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ set -e
88
# For general site-search
99
npm run index-general-search -- src/search/tests/fixtures/search-indexes -l en -l ja -V ghec -V fpt --index-prefix tests
1010

11-
# For general autocomplete search
12-
npm run index-general-autocomplete -- src/search/tests/fixtures/data -l en -l ja -v fpt -v ghec --index-prefix tests
11+
1312

1413
# For AI search autocomplete
1514
npm run index-ai-search-autocomplete -- src/search/tests/fixtures/data -l en -v fpt -v ghec --index-prefix tests

src/search/scripts/index/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@ In production, the indexing happens in the GitHub workflows: `index-autocomplete
1010

1111
Before running the indexing for **general search** you run the [scrape](../scrape/README.md) script to scrape page data into files.
1212

13-
Before running the indexing for **general autocomplete** and **AI search autocomplete** you need to clone [docs-internal-data](https://github.com/github/docs-internal-data) to the root of this directory.
13+
Before running the indexing for **AI search autocomplete** you need to clone [docs-internal-data](https://github.com/github/docs-internal-data) to the root of this directory.
1414

1515
There is a separate run command for indexing each type of search data:
1616
1. **general search**: `npm run index-general-search -- <scrape-directory>`
17-
2. **general autocomplete**: `npm run index-general-autocomplete -- docs-internal-data` (if `docs-internal-data` is cloned to root directory)
18-
3. **AI search autocomplete**: `npm run index-ai-search-autocomplete -- docs-internal-data` (if `docs-internal-data` is cloned to root directory)
17+
2. **AI search autocomplete**: `npm run index-ai-search-autocomplete -- docs-internal-data` (if `docs-internal-data` is cloned to root directory)
1918

2019
To see the arguments accepted by any script, pass the `--help` argument, for example
2120

2221
```bash
23-
npm run index-general-autocomplete -- --help
22+
npm run index-ai-search-autocomplete -- --help
2423
```

0 commit comments

Comments
 (0)