This repository was archived by the owner on Jun 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathscore.js
More file actions
40 lines (40 loc) · 1.58 KB
/
score.js
File metadata and controls
40 lines (40 loc) · 1.58 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
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function getFunctionScores(config) {
var _a;
if (!config.elasticsearch.hasOwnProperty('searchScoring')) {
return false;
}
var filter = [];
var esScoringAttributes = config.elasticsearch.searchScoring.attributes;
var esScoringConfig = config.elasticsearch.searchScoring;
if (!Object.keys(esScoringAttributes).length) {
return false;
}
for (var _i = 0, _b = Object.keys(esScoringAttributes); _i < _b.length; _i++) {
var attribute = _b[_i];
for (var _c = 0, _d = Object.keys(esScoringAttributes[attribute].scoreValues); _c < _d.length; _c++) {
var scoreValue = _d[_c];
var data = {
'filter': {
'match': (_a = {},
_a[attribute] = scoreValue,
_a)
},
'weight': esScoringAttributes[attribute].scoreValues[scoreValue].weight
};
filter.push(data);
}
}
if (filter.length) {
return { 'functions': filter,
'score_mode': esScoringConfig.score_mode ? esScoringConfig.score_mode : 'multiply',
'boost_mode': esScoringConfig.boost_mode ? esScoringConfig.boost_mode : 'multiply',
'max_boost': esScoringConfig.max_boost ? esScoringConfig.max_boost : 100,
'min_score': esScoringConfig.function_min_score ? esScoringConfig.function_min_score : 1
};
}
return false;
}
exports.default = getFunctionScores;
//# sourceMappingURL=score.js.map