Browse Source

Use `pelias.json` to inform boost configuration

cb_sorting
Julian Simioni 6 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 textParser = require('./text_parser_addressit');
const check = require('check-types'); const check = require('check-types');
const logger = require('pelias-logger').get('api'); 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) // additional views (these may be merged in to pelias/query at a later date)
var views = { var views = {
custom_boosts: require('./view/boost_sources_and_layers'),
ngrams_strict: require('./view/ngrams_strict'), ngrams_strict: require('./view/ngrams_strict'),
ngrams_last_token_only: require('./view/ngrams_last_token_only'), ngrams_last_token_only: require('./view/ngrams_last_token_only'),
phrase_first_tokens_only: require('./view/phrase_first_tokens_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.popularity( views.pop_subquery ) );
query.score( peliasQuery.view.population( views.pop_subquery ) ); query.score( peliasQuery.view.population( views.pop_subquery ) );
const boostView = require( './view/boost_sources_and_layers' ); const boostConfig = config.customBoosts || {};
query.score( views.custom_boosts(config.customBoosts) );
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) );
// non-scoring hard filters // non-scoring hard filters
query.filter( peliasQuery.view.sources ); query.filter( peliasQuery.view.sources );

4
schema.js

@ -20,6 +20,10 @@ module.exports = Joi.object().keys({
accessLog: Joi.string(), accessLog: Joi.string(),
relativeScores: Joi.boolean(), relativeScores: Joi.boolean(),
requestRetries: Joi.number().integer().min(0), requestRetries: Joi.number().integer().min(0),
customBoosts: Joi.object().keys({
layer: Joi.object(),
source: Joi.object()
}),
localization: Joi.object().keys({ localization: Joi.object().keys({
flipNumberAndStreetCountries: Joi.array().items(Joi.string().regex(/^[A-Z]{3}$/)) flipNumberAndStreetCountries: Joi.array().items(Joi.string().regex(/^[A-Z]{3}$/))
}).unknown(false), }).unknown(false),

Loading…
Cancel
Save