1 |
|
2 | module.exports = function( subview ){
|
3 | return function( vs ){
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | if( !subview ){ return null; }
|
9 |
|
10 |
|
11 | if( !vs.isset('popularity:field') ||
|
12 | !vs.isset('popularity:modifier') ||
|
13 | !vs.isset('popularity:max_boost') ){
|
14 | return null;
|
15 | }
|
16 |
|
17 |
|
18 | var view = {
|
19 | function_score: {
|
20 | query: subview( vs ),
|
21 | max_boost: vs.var('popularity:max_boost'),
|
22 | functions: [],
|
23 | score_mode: 'first',
|
24 | boost_mode: 'replace'
|
25 | }
|
26 | };
|
27 |
|
28 | view.function_score.functions.push({
|
29 | field_value_factor: {
|
30 | modifier: vs.var('popularity:modifier'),
|
31 | field: vs.var('popularity:field'),
|
32 | missing: 1
|
33 | },
|
34 | weight: vs.var('popularity:weight')
|
35 | });
|
36 |
|
37 | return view;
|
38 | };
|
39 | };
|