From 79f33dee96f39eed760f6e2954d03ea6bc91f69e Mon Sep 17 00:00:00 2001 From: Harish Krishna Date: Thu, 26 Feb 2015 12:33:02 -0500 Subject: [PATCH 1/2] adding popularity to sort scoring function list --- query/sort.js | 8 ++++++++ test/unit/query/reverse.js | 11 ++++++++++- test/unit/query/search.js | 11 ++++++++++- test/unit/query/sort.js | 8 ++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/query/sort.js b/query/sort.js index 7102651f..d79f39b8 100644 --- a/query/sort.js +++ b/query/sort.js @@ -1,4 +1,5 @@ var population = 'population'; +var popularity = 'popularity'; var weights = require('pelias-suggester-pipeline').weights; module.exports = [ @@ -9,6 +10,13 @@ module.exports = [ 'order': 'desc' } }, + { + '_script': { + 'file': popularity, + 'type': 'number', + 'order': 'desc' + } + }, { '_script': { 'params': { diff --git a/test/unit/query/reverse.js b/test/unit/query/reverse.js index 26c5e7e9..08550c71 100644 --- a/test/unit/query/reverse.js +++ b/test/unit/query/reverse.js @@ -1,5 +1,7 @@ var generate = require('../../../query/reverse'); +var population = 'population'; +var popularity = 'popularity'; var weights = require('pelias-suggester-pipeline').weights; module.exports.tests = {}; @@ -15,7 +17,14 @@ var sort = [ '_score', { '_script': { - 'file': 'population', + 'file': population, + 'type': 'number', + 'order': 'desc' + } + }, + { + '_script': { + 'file': popularity, 'type': 'number', 'order': 'desc' } diff --git a/test/unit/query/search.js b/test/unit/query/search.js index 3e9d72f0..d47246b6 100644 --- a/test/unit/query/search.js +++ b/test/unit/query/search.js @@ -1,5 +1,7 @@ var generate = require('../../../query/search'); +var population = 'population'; +var popularity = 'popularity'; var weights = require('pelias-suggester-pipeline').weights; module.exports.tests = {}; @@ -15,7 +17,14 @@ var sort = [ '_score', { '_script': { - 'file': 'population', + 'file': population, + 'type': 'number', + 'order': 'desc' + } + }, + { + '_script': { + 'file': popularity, 'type': 'number', 'order': 'desc' } diff --git a/test/unit/query/sort.js b/test/unit/query/sort.js index ad5f9037..95e2a02e 100644 --- a/test/unit/query/sort.js +++ b/test/unit/query/sort.js @@ -1,6 +1,7 @@ var generate = require('../../../query/sort'); var population = 'population'; +var popularity = 'popularity'; var weights = require('pelias-suggester-pipeline').weights; module.exports.tests = {}; @@ -20,6 +21,13 @@ var expected = [ 'order': 'desc' } }, + { + '_script': { + 'file': popularity, + 'type': 'number', + 'order': 'desc' + } + }, { '_script': { 'params': { From 28e3d3943e0199e52f383ba58e45d6ba6f0ad03a Mon Sep 17 00:00:00 2001 From: Harish Krishna Date: Mon, 16 Mar 2015 16:27:24 -0400 Subject: [PATCH 2/2] consistent naming convention --- test/unit/query/sort.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/unit/query/sort.js b/test/unit/query/sort.js index 37d1590d..4c3e6249 100644 --- a/test/unit/query/sort.js +++ b/test/unit/query/sort.js @@ -1,5 +1,6 @@ var generate = require('../../../query/sort'); +var admin_boost = 'admin_boost'; var population = 'population'; var popularity = 'popularity'; var weights = require('pelias-suggester-pipeline').weights; @@ -16,7 +17,7 @@ module.exports.tests.interface = function(test, common) { var expected = [ { '_script': { - 'file': 'admin_boost', + 'file': admin_boost, 'type': 'number', 'order': 'desc' }