1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | module.exports = function( vs, fields_with_boosts, analyzer, query_var ){
|
15 |
|
16 | var view = { multi_match: {} };
|
17 |
|
18 | if (!vs.isset(query_var) || !analyzer) {
|
19 | return null;
|
20 | }
|
21 |
|
22 |
|
23 |
|
24 | var fields = fields_with_boosts.map(function(data) {
|
25 | var fieldString = data.field;
|
26 | var boost = data.boost || 1;
|
27 | return fieldString +'^' + boost;
|
28 | });
|
29 |
|
30 | view.multi_match.fields = fields;
|
31 | view.multi_match.query = vs.var(query_var);
|
32 | view.multi_match.analyzer = analyzer;
|
33 |
|
34 | if (vs.isset('multi_match:type')) {
|
35 | view.multi_match.type = vs.var('multi_match:type');
|
36 | }
|
37 |
|
38 | if (vs.isset('multi_match:operator')) {
|
39 | view.multi_match.operator = vs.var('multi_match:operator');
|
40 | }
|
41 |
|
42 | if (vs.isset('multi_match:cutoff_frequency')) {
|
43 | view.multi_match.cutoff_frequency = vs.var('multi_match:cutoff_frequency');
|
44 | }
|
45 |
|
46 | return view;
|
47 | };
|