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. 6
      test/unit/query/search.js
  5. 6
      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 popularity = 'popularity';
var category = 'category'; var category = 'category';
var category_weights = require('../helper/category_weights'); var category_weights = require('../helper/category_weights');
var admin_weights = require('../helper/admin_weights');
var weights = require('pelias-suggester-pipeline').weights; var weights = require('pelias-suggester-pipeline').weights;
var isObject = require( 'is-object' ); var isObject = require( 'is-object' );
@ -10,7 +11,10 @@ module.exports = function( params ){
var scriptsConfig = [ var scriptsConfig = [
{ {
'_script': { '_script': {
'file': admin_boost, 'params': {
'weights': admin_weights
},
'file': 'weights',
'type': 'number', 'type': 'number',
'order': 'desc' 'order': 'desc'
} }

6
test/unit/query/reverse.js

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

6
test/unit/query/search.js

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

6
test/unit/query/sort.js

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

Loading…
Cancel
Save