diff --git a/test/view/multi_match.js b/test/view/multi_match.js index 5730040..0116353 100644 --- a/test/view/multi_match.js +++ b/test/view/multi_match.js @@ -125,6 +125,40 @@ module.exports.tests.type = function (test, common) { }; +module.exports.tests.operator = function (test, common) { + test('optional operator', function (t) { + var vs = new VariableStore(); + vs.var('query var', 'query value'); + vs.var('multi_match:operator', 'and'); + + var fields_with_boosts = [ + { field: 'field 1' }, + { field: 'field 2' }, + { field: 'field 3' } + ]; + + var actual = multi_match(vs, fields_with_boosts, 'analyzer value', 'query var'); + + var expected = { + multi_match: { + fields: [ + 'field 1^1', + 'field 2^1', + 'field 3^1' + ], + query: { $: 'query value' }, + analyzer: 'analyzer value', + operator: { $: 'and' }, + } + }; + + t.deepEquals(actual, expected, 'should have returned object'); + t.end(); + + }); + +}; + module.exports.all = function (tape, common) { function test(name, testFunction) { return tape('multi_match ' + name, testFunction); diff --git a/view/multi_match.js b/view/multi_match.js index 72c0c75..f982b71 100644 --- a/view/multi_match.js +++ b/view/multi_match.js @@ -35,6 +35,10 @@ module.exports = function( vs, fields_with_boosts, analyzer, query_var ){ view.multi_match.type = vs.var('multi_match:type'); } + if (vs.isset('multi_match:operator')) { + view.multi_match.operator = vs.var('multi_match:operator'); + } + if (vs.isset('multi_match:cutoff_frequency')) { view.multi_match.cutoff_frequency = vs.var('multi_match:cutoff_frequency'); }