Skip to content

Commit

Permalink
Stop indexing GHAE in Elasticsearch (#48694)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbe committed Jan 19, 2024
1 parent df51240 commit 8dd3a5a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
10 changes: 9 additions & 1 deletion src/search/scripts/index-elasticsearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ import { retryOnErrorTest } from './retry-on-error-test.js'
import { languageKeys } from '#src/languages/lib/languages.js'
import { allVersions } from '#src/versions/lib/all-versions.js'

const availableVersions = Object.fromEntries(
Object.entries(allVersions)
// GHAE is deprecated and not yet entirely deleted from all-versions
// Until so, we manually filter it out.
.filter(([version]) => version !== 'github-ae@latest')
.map(([key, value]) => [key, value]),
)

// Now you can optionally have set the ELASTICSEARCH_URL in your .env file.
dotenv.config()

Expand All @@ -38,7 +46,7 @@ dotenv.config()
// We need this later to be able to map CLI arguments to what the
// records are called when found on disk.
const shortNames = Object.fromEntries(
Object.values(allVersions).map((info) => {
Object.values(availableVersions).map((info) => {
const shortName = info.hasNumberedReleases
? info.miscBaseName + info.currentRelease
: info.miscBaseName
Expand Down
13 changes: 10 additions & 3 deletions src/search/scripts/sync-search-indices.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,23 @@ import { languageKeys } from '#src/languages/lib/languages.js'
import { allVersions } from '#src/versions/lib/all-versions.js'
import searchSync from './sync.js'

const availableVersions = Object.fromEntries(
Object.entries(allVersions)
// GHAE is deprecated and not yet entirely deleted from all-versions
// Until so, we manually filter it out.
.filter(([version]) => version !== 'github-ae@latest')
.map(([key, value]) => [key, value]),
)
const shortNames = Object.fromEntries(
Object.values(allVersions).map((info) => {
Object.values(availableVersions).map((info) => {
const shortName = info.hasNumberedReleases
? info.miscBaseName + info.currentRelease
: info.miscBaseName
return [shortName, info]
}),
)

const allVersionKeys = [...Object.keys(shortNames), ...Object.keys(allVersions)]
const allVersionKeys = [...Object.keys(shortNames), ...Object.keys(availableVersions)]

program
.description('Creates search records by scraping')
Expand Down Expand Up @@ -133,9 +140,9 @@ async function main(opts, args) {
const options = {
language,
notLanguage,
version: indexVersion,
outDirectory,
config,
versionsToBuild: indexVersion ? [indexVersion] : Object.keys(availableVersions),
}
await searchSync(options)
}
9 changes: 2 additions & 7 deletions src/search/scripts/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import { writeIndexRecords } from './search-index-records.js'
// e.g. `github-docs-dotcom-en.json` and `github-docs-2.14-ja.json`
export default async function syncSearchIndexes({
language,
version,
notLanguage,
outDirectory,
versionsToBuild,
config = {},
}) {
const t0 = new Date()
Expand All @@ -24,14 +24,9 @@ export default async function syncSearchIndexes({
notLanguage ? notLanguage !== lang : language ? language === lang : true,
)

// build indices for a specific version if provided; otherwise build indices for all versions
const versionsToBuild = Object.keys(allVersions).filter((ver) =>
version ? version === ver : true,
)

console.log(
`Building indices for ${chalk.yellow(language || 'all languages')} and ${chalk.yellow(
version || 'all versions',
versionsToBuild.length === 1 ? versionsToBuild[0] : 'all versions',
)}.\n`,
)

Expand Down

0 comments on commit 8dd3a5a

Please sign in to comment.