Skip to content

Commit 791606c

Browse files
committed
feat(multi_match): support operator on multi_match queries
1 parent 2438c13 commit 791606c

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

test/view/multi_match.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,40 @@ module.exports.tests.type = function (test, common) {
125125

126126
};
127127

128+
module.exports.tests.operator = function (test, common) {
129+
test('optional operator', function (t) {
130+
var vs = new VariableStore();
131+
vs.var('query var', 'query value');
132+
vs.var('multi_match:operator', 'and');
133+
134+
var fields_with_boosts = [
135+
{ field: 'field 1' },
136+
{ field: 'field 2' },
137+
{ field: 'field 3' }
138+
];
139+
140+
var actual = multi_match(vs, fields_with_boosts, 'analyzer value', 'query var');
141+
142+
var expected = {
143+
multi_match: {
144+
fields: [
145+
'field 1^1',
146+
'field 2^1',
147+
'field 3^1'
148+
],
149+
query: { $: 'query value' },
150+
analyzer: 'analyzer value',
151+
operator: { $: 'and' },
152+
}
153+
};
154+
155+
t.deepEquals(actual, expected, 'should have returned object');
156+
t.end();
157+
158+
});
159+
160+
};
161+
128162
module.exports.all = function (tape, common) {
129163
function test(name, testFunction) {
130164
return tape('multi_match ' + name, testFunction);

view/multi_match.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ module.exports = function( vs, fields_with_boosts, analyzer, query_var ){
3535
view.multi_match.type = vs.var('multi_match:type');
3636
}
3737

38+
if (vs.isset('multi_match:operator')) {
39+
view.multi_match.operator = vs.var('multi_match:operator');
40+
}
41+
3842
if (vs.isset('multi_match:cutoff_frequency')) {
3943
view.multi_match.cutoff_frequency = vs.var('multi_match:cutoff_frequency');
4044
}

0 commit comments

Comments
 (0)