Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

category scoring #106

Merged
merged 3 commits into from
Apr 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions helper/category_weights.js
Original file line number Diff line number Diff line change
@@ -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
};
12 changes: 12 additions & 0 deletions query/sort.js
Original file line number Diff line number Diff line change
@@ -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 = [
Expand All @@ -25,6 +27,16 @@ module.exports = [
'order': 'desc'
}
},
{
'_script': {
'params': {
'category_weights': category_weights
},
'file': category,
'type': 'number',
'order': 'desc'
}
},
{
'_script': {
'params': {
Expand Down
12 changes: 12 additions & 0 deletions test/unit/query/reverse.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down Expand Up @@ -37,6 +39,16 @@ var sort = [
'order': 'desc'
}
},
{
'_script': {
'params': {
'category_weights': category_weights
},
'file': category,
'type': 'number',
'order': 'desc'
}
},
{
'_script': {
'params': {
Expand Down
12 changes: 12 additions & 0 deletions test/unit/query/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down Expand Up @@ -37,6 +39,16 @@ var sort = [
'order': 'desc'
}
},
{
'_script': {
'params': {
'category_weights': category_weights
},
'file': category,
'type': 'number',
'order': 'desc'
}
},
{
'_script': {
'params': {
Expand Down
12 changes: 12 additions & 0 deletions test/unit/query/sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down Expand Up @@ -35,6 +37,16 @@ var expected = [
'type': 'number',
'order': 'desc'
}
},
{
'_script': {
'params': {
'category_weights': category_weights
},
'file': category,
'type': 'number',
'order': 'desc'
}
},
{
'_script': {
Expand Down