Skip to content

Commit

Permalink
Merge pull request #99 from pelias/multi_match_operator
Browse files Browse the repository at this point in the history
support operator on multi_match queries
  • Loading branch information
missinglink authored May 15, 2019
2 parents 2438c13 + 791606c commit ae3912b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/view/multi_match.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions view/multi_match.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down

0 comments on commit ae3912b

Please sign in to comment.