Browse Source

Use `pelias.json` to inform boost configuration

cb_sorting
Julian Simioni 7 years ago
parent
commit
391d815ea5
No known key found for this signature in database
GPG Key ID: B9EEB0C6EE0910A1
  1. 16
      query/autocomplete.js
  2. 4
      schema.js

16
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 );

4
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),

Loading…
Cancel
Save