Skip to content

Commit

Permalink
feat(terms): Allow extra parameters including boost
Browse files Browse the repository at this point in the history
  • Loading branch information
orangejulius committed Sep 6, 2019
1 parent 89d45cb commit bf0c689
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/leaf/terms.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = function( property, value ){
module.exports = function( property, value, parameters ){
if( !property || !value) {
return null;
}
Expand All @@ -9,5 +9,9 @@ module.exports = function( property, value ){
}
};

if (parameters && parameters.boost) {
query.terms.boost = parameters.boost;
}

return query;
};
14 changes: 14 additions & 0 deletions test/lib/leaf/terms.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ module.exports.tests.terms = function(test, common) {
t.deepEqual(query, expected, 'valid terms query');
t.end();
});

test('terms query can handle optional boost parameter', function(t) {
const query = terms('property', 'value', { boost: 5});

const expected = {
terms: {
property: 'value',
boost: 5
}
};

t.deepEqual(query, expected, 'valid terms query with boost');
t.end();
});
};

module.exports.all = function (tape, common) {
Expand Down

0 comments on commit bf0c689

Please sign in to comment.