Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const defaults = require('./search_defaults');
const textParser = require('./text_parser_pelias');
const config = require('pelias-config').generate().api;
var placeTypes = require('../helper/placeTypes');
var views = { custom_boosts: require('./view/boost_sources_and_layers') };
// region_a is also an admin field which can be identified by
// the pelias_parser. this functionality was inherited from the
// previous parser we used prior to the creation of pelias_parser.
var adminFields = placeTypes.concat(['region_a']);
//------------------------------
// general-purpose search query
//------------------------------
var query = new peliasQuery.layout.FilteredBooleanQuery();
// mandatory matches
query.score( peliasQuery.view.ngrams, 'must' );
// scoring boost
const phrase_view = peliasQuery.view.leaf.match_phrase('main');
query.score( phrase_view );
query.score( peliasQuery.view.focus( phrase_view ) );
query.score( peliasQuery.view.popularity( peliasQuery.view.leaf.match_all ) );
query.score( peliasQuery.view.population( peliasQuery.view.leaf.match_all ) );
// address components
query.score( peliasQuery.view.address('housenumber') );
query.score( peliasQuery.view.address('street') );
query.score( peliasQuery.view.address('cross_street') );
const _ = require('lodash');
const peliasQuery = require('pelias-query');
const defaults = require('./search_defaults');
const textParser = require('./text_parser');
//------------------------------
// general-purpose search query
//------------------------------
const structuredQuery = new peliasQuery.layout.StructuredFallbackQuery();
// scoring boost
structuredQuery.score( peliasQuery.view.focus_only_function( ) );
structuredQuery.score( peliasQuery.view.popularity_only_function );
structuredQuery.score( peliasQuery.view.population_only_function );
// --------------------------------
// non-scoring hard filters
structuredQuery.filter( peliasQuery.view.boundary_country );
structuredQuery.filter( peliasQuery.view.boundary_circle );
structuredQuery.filter( peliasQuery.view.boundary_rect );
structuredQuery.filter( peliasQuery.view.sources );
structuredQuery.filter( peliasQuery.view.layers );
structuredQuery.filter( peliasQuery.view.categories );
structuredQuery.filter( peliasQuery.view.boundary_gid );
// --------------------------------
const _ = require('lodash');
const peliasQuery = require('pelias-query');
const defaults = require('./search_defaults');
const textParser = require('./text_parser');
//------------------------------
// general-purpose search query
//------------------------------
var fallbackQuery = new peliasQuery.layout.FallbackQuery();
// scoring boost
fallbackQuery.score( peliasQuery.view.focus_only_function( ) );
fallbackQuery.score( peliasQuery.view.popularity_only_function );
fallbackQuery.score( peliasQuery.view.population_only_function );
// --------------------------------
// non-scoring hard filters
fallbackQuery.filter( peliasQuery.view.boundary_country );
fallbackQuery.filter( peliasQuery.view.boundary_circle );
fallbackQuery.filter( peliasQuery.view.boundary_rect );
fallbackQuery.filter( peliasQuery.view.sources );
fallbackQuery.filter( peliasQuery.view.layers );
fallbackQuery.filter( peliasQuery.view.categories );
fallbackQuery.filter( peliasQuery.view.boundary_gid );
// --------------------------------
// add some name field(s) to the admin fields in order to improve venue matching
// note: this is a bit of a hacky way to add a 'name' field to the list
// of multimatch fields normally reserved for admin subquerying.
// in some cases we are not sure if certain tokens refer to admin components
// or are part of the place name (such as some venue names).
// the variable name 'add_name_to_multimatch' is arbitrary, it can be any value so
// long as there is a corresponding 'admin:*:field' variable set which defines
// the name of the field to use.
// this functionality is not enabled unless the 'input:add_name_to_multimatch'
// variable is set to a non-empty value at query-time.
adminFields = adminFields.concat(['add_name_to_multimatch']);
//------------------------------
// autocomplete query
//------------------------------
var query = new peliasQuery.layout.FilteredBooleanQuery();
// mandatory matches
query.score( views.phrase_first_tokens_only, 'must' );
query.score( views.ngrams_last_token_only_multi( adminFields ), 'must' );
// admin components
query.score( views.admin_multi_match_first( adminFields ), 'must');
query.score( views.admin_multi_match_last( adminFields ), 'must');
// address components
query.score( peliasQuery.view.address('housenumber') );
query.score( peliasQuery.view.address('street') );
query.score( peliasQuery.view.address('cross_street') );
query.score( peliasQuery.view.address('postcode') );
// scoring boost
const _ = require('lodash');
const peliasQuery = require('pelias-query');
const defaults = require('./reverse_defaults');
//------------------------------
// reverse geocode query
//------------------------------
var query = new peliasQuery.layout.FilteredBooleanQuery();
// mandatory matches
// (none)
// scoring boost
query.sort( peliasQuery.view.sort_distance );
// non-scoring hard filters
query.filter( peliasQuery.view.boundary_circle );
query.filter( peliasQuery.view.sources );
query.filter( peliasQuery.view.layers );
query.filter( peliasQuery.view.categories );
query.filter( peliasQuery.view.boundary_country );
query.filter( peliasQuery.view.boundary_gid );
// --------------------------------
const _ = require('lodash');
const peliasQuery = require('pelias-query');
const defaults = require('./search_defaults');
//------------------------------
// general-purpose search query
//------------------------------
const addressUsingIdsQuery = new peliasQuery.layout.AddressesUsingIdsQuery();
// scoring boost
addressUsingIdsQuery.score( peliasQuery.view.focus_only_function( ) );
// --------------------------------
// non-scoring hard filters
addressUsingIdsQuery.filter( peliasQuery.view.boundary_country );
addressUsingIdsQuery.filter( peliasQuery.view.boundary_circle );
addressUsingIdsQuery.filter( peliasQuery.view.boundary_rect );
addressUsingIdsQuery.filter( peliasQuery.view.sources );
addressUsingIdsQuery.filter( peliasQuery.view.boundary_gid );
// --------------------------------
// This query is a departure from traditional Pelias queries where textual
// names of admin areas were looked up. This query uses the ids returned by
// placeholder for lookups which dramatically reduces the amount of information
const peliasQuery = require('pelias-query');
const defaults = require('./search_defaults');
const logger = require('pelias-logger').get('api');
const _ = require('lodash');
const check = require('check-types');
//------------------------------
// general-purpose search query
//------------------------------
const venuesQuery = new peliasQuery.layout.VenuesQuery();
// scoring boost
venuesQuery.score( peliasQuery.view.focus_only_function( peliasQuery.view.phrase ) );
// --------------------------------
// non-scoring hard filters
venuesQuery.filter( peliasQuery.view.boundary_country );
venuesQuery.filter( peliasQuery.view.boundary_circle );
venuesQuery.filter( peliasQuery.view.boundary_rect );
venuesQuery.filter( peliasQuery.view.sources );
// --------------------------------
const adminLayers = ['neighbourhood', 'borough', 'city', 'county', 'state', 'country'];
/**
map request variables to query variables for all inputs