Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// http://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-root-object-type.html#_dynamic_templates
const elastictest = require('elastictest');
const config = require('pelias-config').generate();
module.exports.tests = {};
module.exports.tests.dynamic_templates_name = function(test, common){
test( 'document->name', nameAssertion( 'peliasIndexOneEdgeGram', common ) );
};
module.exports.tests.dynamic_templates_phrase = function(test, common){
test( 'document->phrase', phraseAssertion( 'peliasPhrase', common ) );
};
module.exports.tests.dynamic_templates_addendum = function(test, common){
test( 'addendum', addendumAssertion( 'wikipedia', JSON.stringify({ slug: 'Wikipedia' }), common ) );
};
module.exports.all = function (tape, common) {
var peliasConfig = require( 'pelias-config' ).generate(require('./schema'));
var readStreamModule = require('./src/readStream');
var importStream = require('./src/importStream');
var peliasDbclient = require( 'pelias-dbclient' );
var peliasDocGenerators = require('./src/peliasDocGenerators');
var hierarchyFinder = require('./src/hierarchyFinder');
var bundles = require('./src/bundleList');
const logger = require( 'pelias-logger' ).get( 'whosonfirst' );
// a cache of only admin records, to be used to fill the hierarchy
// of other, lower admin records as well as venues
var wofAdminRecords = {};
bundles.generateBundleList((err, bundlesToImport) => {
if (err) {
function extract(options, callback){
// load configuration variables
const config = require('pelias-config').generate(require('../schema')).imports.whosonfirst;
// location of data and meta dirs
const metaDir = path.join(config.datapath, 'meta');
const dataDir = path.join(config.datapath, 'data');
const sqliteDir = path.join(config.datapath, 'sqlite');
// unlink (truncate meta and data dirs)
if( options && true === options.unlink ){
fs.removeSync(metaDir);
fs.removeSync(dataDir);
}
// ensure required directory structure exists
fs.ensureDirSync(metaDir);
fs.ensureDirSync(dataDir);
fs.ensureDirSync(sqliteDir);
/**
The pbf parser is responsible for configuring and executing a pbf parser and
returning a valid readable stream.
**/
var fs = require('fs'),
pbf2json = require('pbf2json'),
settings = require('pelias-config').generate(require('../schema')),
features = require('../config/features'),
path = require('path');
// Create a new pbf parser stream
function createPbfStream(opts){
var conf = config(opts);
validatePath( conf.file, 'failed to stat pbf file: ' + conf.file );
validatePath( conf.leveldb, 'failed to stat leveldb path: ' + conf.leveldb );
validateTags( conf.tags );
return pbf2json.createReadStream(conf);
}
// Generate configuration options for pbf2json, apply default
const _ = require('lodash');
const peliasQuery = require('pelias-query');
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' );
const _ = require('lodash');
const path = require('path');
const schema = require('../');
const fixture = require('./fixtures/expected.json');
const config = require('pelias-config').generate();
const forEachDeep = (obj, cb) =>
_.forEach(obj, (val, key) => {
cb(val, key);
if (_.isPlainObject(val) || _.isArray(val)){
forEachDeep(val, cb);
}
});
module.exports.tests = {};
module.exports.tests.compile = function(test, common) {
test('valid schema file', function(t) {
t.equal(typeof schema, 'object', 'schema generated');
t.equal(Object.keys(schema).length>0, true, 'schema has body');
t.end();
function setup(peliasConfig, basePath) {
var opts = {
config: peliasConfig || require('pelias-config').generate().api,
basePath: basePath || '/'
};
function middleware(req, res, next) {
return convertToGeocodeJSON(req, res, next, opts);
}
return middleware;
}
const peliasConfig = require('pelias-config').generate(require('./schema'));
const _ = require('lodash');
const logger = require('pelias-logger').get('openstreetmap');
if (_.has(peliasConfig, 'imports.openstreetmap.adminLookup')) {
logger.info('imports.openstreetmap.adminLookup has been deprecated, ' +
'enable adminLookup using imports.adminLookup.enabled = true');
}
const importPipeline = require('./stream/importPipeline');
importPipeline.import();
const config = require( 'pelias-config' ).generate().esclient;
const client = require('elasticsearch').Client(config);
module.exports = {
client: client
};
const _ = require('lodash');
const tape = require('tape');
const config = require('pelias-config').generate();
const schema = require('../schema');
const common = {
clientOpts: {
host: 'localhost:9200',
keepAlive: true,
apiVersion: config.esclient.apiVersion
},
create: {
schema: schema,
create: {
include_type_name: false
}
},
summaryMap: (res) => {