diff --git a/helper/category_weights.js b/helper/category_weights.js new file mode 100644 index 00000000..a6b6e8f9 --- /dev/null +++ b/helper/category_weights.js @@ -0,0 +1,119 @@ +/** + * These values specify how much a record that matches a certain category + * should be boosted in elasticsearch results. + */ + +module.exports = { + 'transport': 10, + 'transport:air': 20, + 'transport:air:aerodrome': 20, + 'transport:air:airport': 20, + 'recreation': 10, + 'religion': 10, + 'education': 10, + 'entertainment': 10, + 'nightlife': 10, + 'food': 10, + 'government': 10, + 'professional': 10, + 'finance': 10, + 'health': 10, + 'retail': 10, + 'transport:public': 10, + 'transport:bus': 10, + 'transport:taxi': 10, + 'transport:sea': 10, + 'accomodation': 10, + 'transport:station': 10, + 'food:bagel': 10, + 'food:barbecue': 10, + 'food:bougatsa': 10, + 'food:burger': 10, + 'food:cake': 10, + 'food:casserole': 10, + 'food:chicken': 10, + 'food:coffee_shop': 10, + 'food:crepe': 10, + 'food:couscous': 10, + 'food:curry': 10, + 'food:dessert': 10, + 'food:donut': 10, + 'food:empanada': 10, + 'food:fish': 10, + 'food:fish_and_chips': 10, + 'food:fried_food': 10, + 'food:friture': 10, + 'food:gyro': 10, + 'food:ice_cream': 10, + 'food:kebab': 10, + 'food:mediterranean': 10, + 'food:noodle': 10, + 'food:pancake': 10, + 'food:pasta': 10, + 'food:pie': 10, + 'food:pizza': 10, + 'food:regional': 10, + 'food:sandwich': 10, + 'food:sausage': 10, + 'food:savory_pancakes': 10, + 'food:seafood': 10, + 'food:steak': 10, + 'food:sub': 10, + 'food:sushi': 10, + 'food:tapas': 10, + 'food:vegan': 10, + 'food:vegetarian': 10, + 'food:wings': 10, + 'food:cuisine:african': 10, + 'food:cuisine:american': 10, + 'food:cuisine:arab': 10, + 'food:cuisine:argentinian': 10, + 'food:cuisine:asian': 10, + 'food:cuisine:australian': 10, + 'food:cuisine:baiana': 10, + 'food:cuisine:balkan': 10, + 'food:cuisine:basque': 10, + 'food:cuisine:bavarian': 10, + 'food:cuisine:belarusian': 10, + 'food:cuisine:brazilian': 10, + 'food:cuisine:cantonese': 10, + 'food:cuisine:capixaba': 10, + 'food:cuisine:caribbean': 10, + 'food:cuisine:chinese': 10, + 'food:cuisine:croatian': 10, + 'food:cuisine:czech': 10, + 'food:cuisine:danish': 10, + 'food:cuisine:french': 10, + 'food:cuisine:gaucho': 10, + 'food:cuisine:german': 10, + 'food:cuisine:greek': 10, + 'food:cuisine:hunan': 10, + 'food:cuisine:hungarian': 10, + 'food:cuisine:indian': 10, + 'food:cuisine:international': 10, + 'food:cuisine:iranian': 10, + 'food:cuisine:italian': 10, + 'food:cuisine:japanese': 10, + 'food:cuisine:korean': 10, + 'food:cuisine:kyo_ryouri': 10, + 'food:cuisine:latin_american': 10, + 'food:cuisine:lebanese': 10, + 'food:cuisine:malagasy': 10, + 'food:cuisine:mexican': 10, + 'food:cuisine:mineira': 10, + 'food:cuisine:okinawa_ryori': 10, + 'food:cuisine:pakistani': 10, + 'food:cuisine:peruvian': 10, + 'food:cuisine:polish': 10, + 'food:cuisine:portuguese': 10, + 'food:cuisine:rhenish': 10, + 'food:cuisine:russian': 10, + 'food:cuisine:shandong': 10, + 'food:cuisine:sichuan': 10, + 'food:cuisine:spanish': 10, + 'food:cuisine:thai': 10, + 'food:cuisine:turkish': 10, + 'food:cuisine:vietnamese': 10, + 'food:cuisine:westphalian': 10, + 'transport:rail': 10 +}; diff --git a/query/sort.js b/query/sort.js index 2ad6ad5e..c3aa3088 100644 --- a/query/sort.js +++ b/query/sort.js @@ -1,6 +1,8 @@ var admin_boost = 'admin_boost'; var population = 'population'; var popularity = 'popularity'; +var category = 'category'; +var category_weights = require('../helper/category_weights'); var weights = require('pelias-suggester-pipeline').weights; module.exports = [ @@ -25,6 +27,16 @@ module.exports = [ 'order': 'desc' } }, + { + '_script': { + 'params': { + 'category_weights': category_weights + }, + 'file': category, + 'type': 'number', + 'order': 'desc' + } + }, { '_script': { 'params': { diff --git a/test/unit/query/reverse.js b/test/unit/query/reverse.js index 00a3d15e..7c10f52b 100644 --- a/test/unit/query/reverse.js +++ b/test/unit/query/reverse.js @@ -3,6 +3,8 @@ var generate = require('../../../query/reverse'); var admin_boost = 'admin_boost'; var population = 'population'; var popularity = 'popularity'; +var category = 'category'; +var category_weights = require('../../../helper/category_weights'); var weights = require('pelias-suggester-pipeline').weights; module.exports.tests = {}; @@ -37,6 +39,16 @@ var sort = [ 'order': 'desc' } }, + { + '_script': { + 'params': { + 'category_weights': category_weights + }, + 'file': category, + 'type': 'number', + 'order': 'desc' + } + }, { '_script': { 'params': { diff --git a/test/unit/query/search.js b/test/unit/query/search.js index 82a23239..795486cc 100644 --- a/test/unit/query/search.js +++ b/test/unit/query/search.js @@ -3,6 +3,8 @@ var generate = require('../../../query/search'); var admin_boost = 'admin_boost'; var population = 'population'; var popularity = 'popularity'; +var category = 'category'; +var category_weights = require('../../../helper/category_weights'); var weights = require('pelias-suggester-pipeline').weights; module.exports.tests = {}; @@ -37,6 +39,16 @@ var sort = [ 'order': 'desc' } }, + { + '_script': { + 'params': { + 'category_weights': category_weights + }, + 'file': category, + 'type': 'number', + 'order': 'desc' + } + }, { '_script': { 'params': { diff --git a/test/unit/query/sort.js b/test/unit/query/sort.js index 4c3e6249..e507b4cd 100644 --- a/test/unit/query/sort.js +++ b/test/unit/query/sort.js @@ -3,6 +3,8 @@ var generate = require('../../../query/sort'); var admin_boost = 'admin_boost'; var population = 'population'; var popularity = 'popularity'; +var category = 'category'; +var category_weights = require('../../../helper/category_weights'); var weights = require('pelias-suggester-pipeline').weights; module.exports.tests = {}; @@ -35,6 +37,16 @@ var expected = [ 'type': 'number', 'order': 'desc' } + }, + { + '_script': { + 'params': { + 'category_weights': category_weights + }, + 'file': category, + 'type': 'number', + 'order': 'desc' + } }, { '_script': {