Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 37 additions & 3 deletions scripts/algolia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,26 @@ async function indexAndUpload() {
}

if (!isDeveloperDocs) {
await index.setSettings(sentryAlgoliaIndexSettings);
await index.setSettings({
...sentryAlgoliaIndexSettings,
searchableAttributes: [
'unordered(title)',
'unordered(section)',
'unordered(keywords)',
'text',
],
ranking: [
'filters',
'typo',
'words',
'attribute',
'exact',
'proximity',
'desc(sectionRank)',
'asc(position)',
'asc(popularity)',
],
});
}

const totalSeconds = (performance.now() - startTime) / 1000;
Expand Down Expand Up @@ -184,13 +203,28 @@ const frameworkPopularity: Record<string, number> = {
unity: 17,
};

const getPopularity = (sdk: string | undefined, framework: string | undefined) => {
const PRODUCT_DOC_PREFIXES = [
'product/',
'concepts/',
'cli/',
'guides/',
'integrations/',
];

const getPopularity = (
slug: string,
sdk: string | undefined,
framework: string | undefined
) => {
if (sdk && frameworkPopularity[sdk]) {
return frameworkPopularity[sdk];
}
if (framework && frameworkPopularity[framework]) {
return frameworkPopularity[framework];
}
if (PRODUCT_DOC_PREFIXES.some(prefix => slug.startsWith(prefix))) {
return 0;
}
return Number.MAX_SAFE_INTEGER;
};

Expand Down Expand Up @@ -219,7 +253,7 @@ async function getRecords(
keywords: pageFm.keywords,
sdk,
framework,
...(!isDeveloperDocs && {popularity: getPopularity(sdk, framework)}),
...(!isDeveloperDocs && {popularity: getPopularity(pageFm.slug, sdk, framework)}),
};

const cacheFileName = `v${CACHE_VERSION}_${md5(html + JSON.stringify(meta))}.json`;
Expand Down
Loading