Browse Source

adding popularity to sort scoring function list

pull/71/head
Harish Krishna 10 years ago
parent
commit
79f33dee96
  1. 8
      query/sort.js
  2. 11
      test/unit/query/reverse.js
  3. 11
      test/unit/query/search.js
  4. 8
      test/unit/query/sort.js

8
query/sort.js

@ -1,4 +1,5 @@
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 = [
@ -9,6 +10,13 @@ module.exports = [
'order': 'desc' 'order': 'desc'
} }
}, },
{
'_script': {
'file': popularity,
'type': 'number',
'order': 'desc'
}
},
{ {
'_script': { '_script': {
'params': { 'params': {

11
test/unit/query/reverse.js

@ -1,5 +1,7 @@
var generate = require('../../../query/reverse'); var generate = require('../../../query/reverse');
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,14 @@ var sort = [
'_score', '_score',
{ {
'_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/search.js

@ -1,5 +1,7 @@
var generate = require('../../../query/search'); var generate = require('../../../query/search');
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,14 @@ var sort = [
'_score', '_score',
{ {
'_script': { '_script': {
'file': 'population', 'file': population,
'type': 'number',
'order': 'desc'
}
},
{
'_script': {
'file': popularity,
'type': 'number', 'type': 'number',
'order': 'desc' 'order': 'desc'
} }

8
test/unit/query/sort.js

@ -1,6 +1,7 @@
var generate = require('../../../query/sort'); var generate = require('../../../query/sort');
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 = {};
@ -20,6 +21,13 @@ var expected = [
'order': 'desc' 'order': 'desc'
} }
}, },
{
'_script': {
'file': popularity,
'type': 'number',
'order': 'desc'
}
},
{ {
'_script': { '_script': {
'params': { 'params': {

Loading…
Cancel
Save