Browse Source

adding admin_weights instead of just boosting admin0

pull/169/head
Harish Krishna 10 years ago
parent
commit
5025b66a91
  1. 13
      helper/admin_weights.js
  2. 6
      query/sort.js
  3. 6
      test/unit/query/reverse.js
  4. 8
      test/unit/query/search.js
  5. 8
      test/unit/query/sort.js

13
helper/admin_weights.js

@ -0,0 +1,13 @@
/**
* These values specify how much a document that matches a certain _type
* should be boosted in elasticsearch results.
*/
module.exports = {
'admin0': 4,
'admin1': 3,
'admin2': 2,
'local_admin': 1,
'locality':1,
'neighborhood':1
};

6
query/sort.js

@ -3,6 +3,7 @@ var population = 'population';
var popularity = 'popularity';
var category = 'category';
var category_weights = require('../helper/category_weights');
var admin_weights = require('../helper/admin_weights');
var weights = require('pelias-suggester-pipeline').weights;
var isObject = require( 'is-object' );
@ -10,7 +11,10 @@ module.exports = function( params ){
var scriptsConfig = [
{
'_script': {
'file': admin_boost,
'params': {
'weights': admin_weights
},
'file': 'weights',
'type': 'number',
'order': 'desc'
}

6
test/unit/query/reverse.js

@ -5,6 +5,7 @@ var population = 'population';
var popularity = 'popularity';
var category = 'category';
var category_weights = require('../../../helper/category_weights');
var admin_weights = require('../../../helper/admin_weights');
var weights = require('pelias-suggester-pipeline').weights;
module.exports.tests = {};
@ -20,7 +21,10 @@ var sort = [
'_score',
{
'_script': {
'file': admin_boost,
'params': {
'weights': admin_weights
},
'file': 'weights',
'type': 'number',
'order': 'desc'
}

8
test/unit/query/search.js

@ -5,6 +5,7 @@ var population = 'population';
var popularity = 'popularity';
var category = 'category';
var category_weights = require('../../../helper/category_weights');
var admin_weights = require('../../../helper/admin_weights');
var weights = require('pelias-suggester-pipeline').weights;
module.exports.tests = {};
@ -18,9 +19,12 @@ module.exports.tests.interface = function(test, common) {
var sort = [
'_score',
{
{
'_script': {
'file': admin_boost,
'params': {
'weights': admin_weights
},
'file': 'weights',
'type': 'number',
'order': 'desc'
}

8
test/unit/query/sort.js

@ -5,6 +5,7 @@ var population = 'population';
var popularity = 'popularity';
var category = 'category';
var category_weights = require('../../../helper/category_weights');
var admin_weights = require('../../../helper/admin_weights');
var weights = require('pelias-suggester-pipeline').weights;
module.exports.tests = {};
@ -18,9 +19,12 @@ module.exports.tests.interface = function(test, common) {
};
var expected = [
{
{
'_script': {
'file': admin_boost,
'params': {
'weights': admin_weights
},
'file': 'weights',
'type': 'number',
'order': 'desc'
}

Loading…
Cancel
Save