-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathconfig.js
More file actions
101 lines (99 loc) · 2.53 KB
/
Copy pathconfig.js
File metadata and controls
101 lines (99 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import { config } from 'dotenv';
config();
const defaultConfig = {
npmRegistryEndpoint: 'https://replicate.npmjs.com/registry',
npmDownloadsEndpoint: 'https://api.npmjs.org/downloads',
maxObjSize: 450000,
popularDownloadsRatio: 0.005,
appId: 'OFCNCOG2CU',
apiKey: '',
indexName: 'npm-search',
bootstrapIndexName: 'npm-search-bootstrap',
replicateConcurrency: 10,
bootstrapConcurrency: 100,
timeToRedoBootstrap: 7 * 24 * 3600 * 1000 /* one week */,
seq: null,
indexSettings: {
searchableAttributes: [
'unordered(_searchInternal.popularName)',
'unordered(name)',
'unordered(_searchInternal.concatenatedName)',
'unordered(description)',
'unordered(keywords)',
'owner.name',
'owners.name',
],
attributesForFaceting: [
'filterOnly(_searchInternal.concatenatedName)' /* optionalFacetFilters to boost the name */,
'searchable(keywords)',
'searchable(computedKeywords)',
'searchable(owner.name)',
'deprecated',
],
customRanking: [
'desc(_searchInternal.downloadsMagnitude)',
'desc(dependents)',
'desc(downloadsLast30Days)',
],
disablePrefixOnAttributes: ['keywords', 'owner.name', 'owners.name'],
disableExactOnAttributes: [
'description',
'keywords',
'owner.name',
'owners.name',
],
disableTypoToleranceOnAttributes: ['keywords'],
exactOnSingleWordQuery: 'attribute',
ranking: [
'filters',
'typo',
'words',
'proximity',
'attribute',
'asc(deprecated)',
'asc(badPackage)',
'desc(popular)',
'exact',
'custom',
],
optionalWords: ['js', 'javascript'],
separatorsToIndex: '_',
replaceSynonymsInHighlight: false,
},
indexSynonyms: [
{
type: 'synonym',
synonyms: ['_', 'underscore'],
objectID: 'underscore',
},
],
indexRules: [
{
objectID: 'promote-exact',
description: 'promote exact matches',
condition: {
pattern: '{facet:_searchInternal.concatenatedName}',
anchoring: 'is',
},
consequence: {
params: {
automaticOptionalFacetFilters: ['_searchInternal.concatenatedName'],
},
},
},
],
};
export default Object.entries(defaultConfig).reduce(
(res, [key, defaultValue]) => ({
...res,
[key]:
key in process.env
? JSON.parse(
typeof defaultValue === 'string'
? `"${process.env[key]}"`
: process.env[key]
)
: defaultValue,
}),
{}
);