1 |
|
2 |
|
3 |
|
4 |
|
5 | var multi_match = require('./multi_match');
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | module.exports = function( admin_properties, analyzer ){
|
11 | return function( vs ){
|
12 |
|
13 |
|
14 |
|
15 | var valid_admin_properties = admin_properties.filter(function(admin_property) {
|
16 | return admin_property &&
|
17 | vs.isset('input:'+admin_property) &&
|
18 | vs.isset('admin:'+admin_property+':field');
|
19 | });
|
20 |
|
21 | if (valid_admin_properties.length === 0) {
|
22 | return null;
|
23 | }
|
24 |
|
25 |
|
26 |
|
27 | var fields_with_boosts = valid_admin_properties.map(function(admin_property) {
|
28 | var boost = 1;
|
29 | if (vs.isset('admin:' + admin_property + ':boost')) {
|
30 | boost = vs.var('admin:' + admin_property + ':boost');
|
31 | }
|
32 |
|
33 | return {
|
34 | field: vs.var('admin:' + admin_property + ':field'),
|
35 | boost: boost
|
36 | };
|
37 | });
|
38 |
|
39 |
|
40 |
|
41 |
|
42 | var queryVar = 'input:' + valid_admin_properties[0];
|
43 |
|
44 |
|
45 | var view = multi_match(vs, fields_with_boosts, analyzer, queryVar);
|
46 |
|
47 | return view;
|
48 | };
|
49 | };
|