Skip to content

Commit 08b7b0d

Browse files
committed
feat(multi_match): support type on multi_match queries
1 parent 80146a2 commit 08b7b0d

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
@@ -91,6 +91,40 @@ module.exports.tests.cutoff_frequency = function (test, common) {
9191

9292
};
9393

94+
module.exports.tests.type = function (test, common) {
95+
test('optional type', function (t) {
96+
var vs = new VariableStore();
97+
vs.var('query var', 'query value');
98+
vs.var('multi_match:type', 'cross_fields');
99+
100+
var fields_with_boosts = [
101+
{ field: 'field 1' },
102+
{ field: 'field 2' },
103+
{ field: 'field 3' }
104+
];
105+
106+
var actual = multi_match(vs, fields_with_boosts, 'analyzer value', 'query var');
107+
108+
var expected = {
109+
multi_match: {
110+
fields: [
111+
'field 1^1',
112+
'field 2^1',
113+
'field 3^1'
114+
],
115+
query: { $: 'query value' },
116+
analyzer: 'analyzer value',
117+
type: { $: 'cross_fields' },
118+
}
119+
};
120+
121+
t.deepEquals(actual, expected, 'should have returned object');
122+
t.end();
123+
124+
});
125+
126+
};
127+
94128
module.exports.all = function (tape, common) {
95129
function test(name, testFunction) {
96130
return tape('multi_match ' + name, testFunction);

view/multi_match.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ module.exports = function( vs, fields_with_boosts, analyzer, query_var ){
3131
view.multi_match.query = vs.var(query_var);
3232
view.multi_match.analyzer = analyzer;
3333

34+
if (vs.isset('multi_match:type')) {
35+
view.multi_match.type = vs.var('multi_match:type');
36+
}
37+
3438
if (vs.isset('multi_match:cutoff_frequency')) {
3539
view.multi_match.cutoff_frequency = vs.var('multi_match:cutoff_frequency');
3640
}

0 commit comments

Comments
 (0)