From 391d815ea584284dccdbcc33b7fdac46859dc56d Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Wed, 18 Jul 2018 16:07:38 -0400 Subject: [PATCH] Use `pelias.json` to inform boost configuration --- query/autocomplete.js | 16 ++++------------ schema.js | 4 ++++ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/query/autocomplete.js b/query/autocomplete.js index eebceb7c..cba5d2e8 100644 --- a/query/autocomplete.js +++ b/query/autocomplete.js @@ -3,9 +3,11 @@ const defaults = require('./autocomplete_defaults'); const textParser = require('./text_parser_addressit'); const check = require('check-types'); const logger = require('pelias-logger').get('api'); +const config = require('pelias-config').generate().api; // additional views (these may be merged in to pelias/query at a later date) var views = { + custom_boosts: require('./view/boost_sources_and_layers'), ngrams_strict: require('./view/ngrams_strict'), ngrams_last_token_only: require('./view/ngrams_last_token_only'), phrase_first_tokens_only: require('./view/phrase_first_tokens_only'), @@ -45,18 +47,8 @@ query.score( peliasQuery.view.focus( views.ngrams_strict ) ); query.score( peliasQuery.view.popularity( views.pop_subquery ) ); query.score( peliasQuery.view.population( views.pop_subquery ) ); -const boostView = require( './view/boost_sources_and_layers' ); - -const boostConfig = {}; //TODO: empty config to make functional tests pass for now -// example useful config: -//const boostConfig = { - //layer: { - //stops: 5, - //fare: 5, - //station: 1 - //}, -//}; -query.score( boostView(boostConfig) ); +const boostConfig = config.customBoosts || {}; +query.score( views.custom_boosts(config.customBoosts) ); // non-scoring hard filters query.filter( peliasQuery.view.sources ); diff --git a/schema.js b/schema.js index 00c31a2e..dfc4514f 100644 --- a/schema.js +++ b/schema.js @@ -20,6 +20,10 @@ module.exports = Joi.object().keys({ accessLog: Joi.string(), relativeScores: Joi.boolean(), requestRetries: Joi.number().integer().min(0), + customBoosts: Joi.object().keys({ + layer: Joi.object(), + source: Joi.object() + }), localization: Joi.object().keys({ flipNumberAndStreetCountries: Joi.array().items(Joi.string().regex(/^[A-Z]{3}$/)) }).unknown(false),