Browse Source

Merge pull request #71 from pelias/add-popularity

adding popularity to sort scoring function list
pull/74/merge
Harish Krishna 10 years ago
parent
commit
73bf83275e
  1. 8
      query/sort.js
  2. 14
      test/unit/query/reverse.js
  3. 14
      test/unit/query/search.js
  4. 11
      test/unit/query/sort.js

8
query/sort.js

@ -1,5 +1,6 @@
var admin_boost = 'admin_boost'; var admin_boost = 'admin_boost';
var population = 'population'; var population = 'population';
var popularity = 'popularity';
var weights = require('pelias-suggester-pipeline').weights; var weights = require('pelias-suggester-pipeline').weights;
module.exports = [ module.exports = [
@ -17,6 +18,13 @@ module.exports = [
'order': 'desc' 'order': 'desc'
} }
}, },
{
'_script': {
'file': popularity,
'type': 'number',
'order': 'desc'
}
},
{ {
'_script': { '_script': {
'params': { 'params': {

14
test/unit/query/reverse.js

@ -1,5 +1,8 @@
var generate = require('../../../query/reverse'); var generate = require('../../../query/reverse');
var admin_boost = 'admin_boost';
var population = 'population';
var popularity = 'popularity';
var weights = require('pelias-suggester-pipeline').weights; var weights = require('pelias-suggester-pipeline').weights;
module.exports.tests = {}; module.exports.tests = {};
@ -15,14 +18,21 @@ var sort = [
'_score', '_score',
{ {
'_script': { '_script': {
'file': 'admin_boost', 'file': admin_boost,
'type': 'number', 'type': 'number',
'order': 'desc' 'order': 'desc'
} }
}, },
{ {
'_script': { '_script': {
'file': 'population', 'file': population,
'type': 'number',
'order': 'desc'
}
},
{
'_script': {
'file': popularity,
'type': 'number', 'type': 'number',
'order': 'desc' 'order': 'desc'
} }

14
test/unit/query/search.js

@ -1,5 +1,8 @@
var generate = require('../../../query/search'); var generate = require('../../../query/search');
var admin_boost = 'admin_boost';
var population = 'population';
var popularity = 'popularity';
var weights = require('pelias-suggester-pipeline').weights; var weights = require('pelias-suggester-pipeline').weights;
module.exports.tests = {}; module.exports.tests = {};
@ -15,14 +18,21 @@ var sort = [
'_score', '_score',
{ {
'_script': { '_script': {
'file': 'admin_boost', 'file': admin_boost,
'type': 'number', 'type': 'number',
'order': 'desc' 'order': 'desc'
} }
}, },
{ {
'_script': { '_script': {
'file': 'population', 'file': population,
'type': 'number',
'order': 'desc'
}
},
{
'_script': {
'file': popularity,
'type': 'number', 'type': 'number',
'order': 'desc' 'order': 'desc'
} }

11
test/unit/query/sort.js

@ -1,6 +1,8 @@
var generate = require('../../../query/sort'); var generate = require('../../../query/sort');
var admin_boost = 'admin_boost';
var population = 'population'; var population = 'population';
var popularity = 'popularity';
var weights = require('pelias-suggester-pipeline').weights; var weights = require('pelias-suggester-pipeline').weights;
module.exports.tests = {}; module.exports.tests = {};
@ -15,7 +17,7 @@ module.exports.tests.interface = function(test, common) {
var expected = [ var expected = [
{ {
'_script': { '_script': {
'file': 'admin_boost', 'file': admin_boost,
'type': 'number', 'type': 'number',
'order': 'desc' 'order': 'desc'
} }
@ -27,6 +29,13 @@ var expected = [
'order': 'desc' 'order': 'desc'
} }
}, },
{
'_script': {
'file': popularity,
'type': 'number',
'order': 'desc'
}
},
{ {
'_script': { '_script': {
'params': { 'params': {

Loading…
Cancel
Save