Browse Source

Allow the minimum Elasticearch query size to be set per endpoint

Reverse queries don't need as much deduping, for example
pull/1097/head
Julian Simioni 7 years ago
parent
commit
c966e6f6ae
No known key found for this signature in database
GPG Key ID: B9EEB0C6EE0910A1
  1. 8
      middleware/sizeCalculator.js

8
middleware/sizeCalculator.js

@ -9,6 +9,10 @@ var MIN_QUERY_SIZE = 20;
* incorporating padding for dedupe process
*/
function setup(min_size) {
if (min_size === undefined) {
min_size = MIN_QUERY_SIZE;
}
return function setQuerySize(req, res, next) {
if (_.isUndefined(req.clean) || _.isUndefined(req.clean.size)) {
return next();
@ -25,8 +29,8 @@ function setup(min_size) {
* @param {number} cleanSize
* @returns {number}
*/
function calculateSize(cleanSize) {
return Math.max(MIN_QUERY_SIZE, cleanSize * SIZE_PADDING);
function calculateSize(cleanSize, min_size) {
return Math.max(min_size, cleanSize * SIZE_PADDING);
}
module.exports = setup;

Loading…
Cancel
Save