MCPcopy Create free account
hub / github.com/github/docs / indexVersion

Function indexVersion

script/search/index-elasticsearch.js:230–407  ·  view source on GitHub ↗
(
  client,
  indexName,
  version,
  language,
  sourceDirectory,
  verbose = false
)

Source from the content-addressed store, hash-verified

228
229// Consider moving this to lib
230async function indexVersion(
231 client,
232 indexName,
233 version,
234 language,
235 sourceDirectory,
236 verbose = false
237) {
238 // Note, it's a bit "weird" that numbered releases versions are
239 // called the number but that's the convention the previous
240 // search backend used
241 const indexVersion = shortNames[version].hasNumberedReleases
242 ? shortNames[version].currentRelease
243 : shortNames[version].miscBaseName
244 const recordsName = `github-docs-${indexVersion}-${language}`
245
246 const records = await loadRecords(recordsName, sourceDirectory)
247
248 const thisAlias = `${indexName}__${utcTimestamp()}`
249
250 // CREATE INDEX
251 const settings = {
252 analysis: {
253 analyzer: {
254 // We defined to analyzers. Both based on a "common core" with the
255 // `standard` tokenizer. But the second one adds Snowball filter.
256 // That means the tokenization of "Dependency naming" becomes
257 // `[dependency, naming]` in the explicit one and `[depend, name]`
258 // in the Snowball one.
259 // We do this to give a chance to boost the more exact spelling a
260 // bit higher with the assumption that if the user knew exactly
261 // what it was called, we should show that higher.
262 // A great use-case of this when users search for keywords that are
263 // code words like `dependency-name`.
264 text_analyzer_explicit: {
265 filter: ['lowercase', 'stop', 'asciifolding'],
266 tokenizer: 'standard',
267 type: 'custom',
268 },
269 text_analyzer: {
270 filter: ['lowercase', 'stop', 'asciifolding'],
271 tokenizer: 'standard',
272 type: 'custom',
273 },
274 },
275 filter: {
276 // Will later, conditionally, put the snowball configuration here.
277 },
278 },
279 }
280 const snowballLanguage = getSnowballLanguage(language)
281 if (snowballLanguage) {
282 settings.analysis.analyzer.text_analyzer.filter.push('languaged_snowball')
283 settings.analysis.filter.languaged_snowball = {
284 type: 'snowball',
285 language: snowballLanguage,
286 }
287 } else {

Callers 1

indexAllFunction · 0.85

Calls 6

retryOnErrorTestFunction · 0.90
loadRecordsFunction · 0.85
utcTimestampFunction · 0.85
getSnowballLanguageFunction · 0.85
escapeHTMLFunction · 0.85
createMethod · 0.80

Tested by

no test coverage detected