Browse Source

Merge pull request #764 from pelias/staging

Merge Staging to Production
pull/742/merge
Julian Simioni 8 years ago committed by GitHub
parent
commit
e7c9878bd9
  1. 3
      controller/search.js
  2. 2
      index.js
  3. 4
      package.json
  4. 21
      query/autocomplete.js
  5. 28
      query/reverse.js
  6. 36
      query/search.js
  7. 27
      query/search_original.js

3
controller/search.js

@ -64,6 +64,9 @@ function setup( config, backend, query ){
res.meta = meta || {};
// store the query_type for subsequent middleware
res.meta.query_type = renderedQuery.type;
logger.info(`[controller:search] [queryType:${renderedQuery.type}] [es_result_count:` +
(res.data && res.data.length ? res.data.length : 0));
}
logger.debug('[ES response]', docs);
next();

2
index.js

@ -3,5 +3,5 @@ var app = require('./app'),
port = ( process.env.PORT || 3100 );
/** run server on the default setup (single core) **/
console.log( 'listening on ' + port );
console.log( 'pelias is now running on port ' + port );
app.listen( port );

4
package.json

@ -55,9 +55,9 @@
"pelias-config": "2.4.0",
"pelias-labels": "1.5.1",
"pelias-logger": "0.1.0",
"pelias-model": "4.3.0",
"pelias-model": "4.4.0",
"pelias-query": "8.11.0",
"pelias-text-analyzer": "1.6.0",
"pelias-text-analyzer": "1.7.0",
"stats-lite": "2.0.3",
"through2": "^2.0.3"
},

21
query/autocomplete.js

@ -1,8 +1,10 @@
'use strict';
var peliasQuery = require('pelias-query'),
defaults = require('./autocomplete_defaults'),
textParser = require('./text_parser_addressit'),
check = require('check-types');
const peliasQuery = require('pelias-query');
const defaults = require('./autocomplete_defaults');
const textParser = require('./text_parser_addressit');
const check = require('check-types');
const logger = require('pelias-logger').get('api');
// additional views (these may be merged in to pelias/query at a later date)
var views = {
@ -59,16 +61,20 @@ query.filter( peliasQuery.view.boundary_rect );
**/
function generateQuery( clean ){
var vs = new peliasQuery.Vars( defaults );
const vs = new peliasQuery.Vars( defaults );
let logStr = '[query:autocomplete] [parser:addressit] ';
// sources
if( check.array(clean.sources) && clean.sources.length ){
vs.var( 'sources', clean.sources );
logStr += '[param:sources] ';
}
// layers
if( check.array(clean.layers) && clean.layers.length ){
vs.var( 'layers', clean.layers);
logStr += '[param:layers] ';
}
// boundary country
@ -76,6 +82,7 @@ function generateQuery( clean ){
vs.set({
'boundary:country': clean['boundary.country']
});
logStr += '[param:boundary_country] ';
}
// pass the input tokens to the views so they can choose which tokens
@ -108,6 +115,7 @@ function generateQuery( clean ){
'focus:point:lat': clean['focus.point.lat'],
'focus:point:lon': clean['focus.point.lon']
});
logStr += '[param:focus_point] ';
}
// boundary rect
@ -121,6 +129,7 @@ function generateQuery( clean ){
'boundary:rect:bottom': clean['boundary.rect.min_lat'],
'boundary:rect:left': clean['boundary.rect.min_lon']
});
logStr += '[param:boundary_rect] ';
}
// run the address parser
@ -128,6 +137,8 @@ function generateQuery( clean ){
textParser( clean.parsed_text, vs );
}
logger.info(logStr);
return {
type: 'autocomplete',
body: query.render(vs)

28
query/reverse.js

@ -1,6 +1,9 @@
var peliasQuery = require('pelias-query'),
defaults = require('./reverse_defaults'),
check = require('check-types');
'use strict';
const peliasQuery = require('pelias-query');
const defaults = require('./reverse_defaults');
const check = require('check-types');
const logger = require('pelias-logger').get('api');
//------------------------------
// reverse geocode query
@ -23,18 +26,27 @@ query.filter( peliasQuery.view.categories );
function generateQuery( clean ){
var vs = new peliasQuery.Vars( defaults );
const vs = new peliasQuery.Vars( defaults );
let logStr = '[query:reverse] ';
// set size
if( clean.querySize ){
vs.var( 'size', clean.querySize);
logStr += '[param:querySize] ';
}
// sources
vs.var( 'sources', clean.sources);
if( check.array(clean.sources) && clean.sources.length ) {
vs.var('sources', clean.sources);
logStr += '[param:sources] ';
}
// layers
if( check.array(clean.layers) && clean.layers.length ) {
vs.var( 'layers', clean.layers);
logStr += '[param:layers] ';
}
// focus point to score by distance
if( check.number(clean['point.lat']) &&
@ -43,6 +55,7 @@ function generateQuery( clean ){
'focus:point:lat': clean['point.lat'],
'focus:point:lon': clean['point.lon']
});
logStr += '[param:focus_point] ';
}
// bounding circle
@ -57,6 +70,7 @@ function generateQuery( clean ){
'boundary:circle:lon': clean['boundary.circle.lon'],
'boundary:circle:radius': clean['boundary.circle.radius'] + 'km'
});
logStr += '[param:boundary_circle] ';
}
// boundary country
@ -64,13 +78,17 @@ function generateQuery( clean ){
vs.set({
'boundary:country': clean['boundary.country']
});
logStr += '[param:boundary_country] ';
}
// categories
if (clean.categories) {
vs.var('input:categories', clean.categories);
logStr += '[param:categories] ';
}
logger.info(logStr);
return {
type: 'reverse',
body: query.render(vs)

36
query/search.js

@ -1,7 +1,10 @@
var peliasQuery = require('pelias-query'),
defaults = require('./search_defaults'),
textParser = require('./text_parser'),
check = require('check-types');
'use strict';
const peliasQuery = require('pelias-query');
const defaults = require('./search_defaults');
const textParser = require('./text_parser');
const check = require('check-types');
const logger = require('pelias-logger').get('api');
//------------------------------
// general-purpose search query
@ -41,25 +44,35 @@ geodisambiguationQuery.filter( peliasQuery.view.categories );
**/
function generateQuery( clean ){
var vs = new peliasQuery.Vars( defaults );
const vs = new peliasQuery.Vars( defaults );
let logStr = '[query:search] [parser:libpostal] ';
// input text
vs.var( 'input:name', clean.text );
// sources
if( check.array(clean.sources) && clean.sources.length ) {
vs.var( 'sources', clean.sources);
logStr += '[param:sources] ';
}
// layers
vs.var( 'layers', clean.layers);
if( check.array(clean.layers) && clean.layers.length ) {
vs.var('layers', clean.layers);
logStr += '[param:layers] ';
}
// categories
if (clean.categories) {
vs.var('input:categories', clean.categories);
logStr += '[param:categories] ';
}
// size
if( clean.querySize ) {
vs.var( 'size', clean.querySize );
logStr += '[param:querySize] ';
}
// focus point
@ -69,6 +82,7 @@ function generateQuery( clean ){
'focus:point:lat': clean['focus.point.lat'],
'focus:point:lon': clean['focus.point.lon']
});
logStr += '[param:focus_point] ';
}
// boundary rect
@ -82,6 +96,7 @@ function generateQuery( clean ){
'boundary:rect:bottom': clean['boundary.rect.min_lat'],
'boundary:rect:left': clean['boundary.rect.min_lon']
});
logStr += '[param:boundary_rect] ';
}
// boundary circle
@ -98,6 +113,7 @@ function generateQuery( clean ){
'boundary:circle:radius': Math.round( clean['boundary.circle.radius'] ) + 'km'
});
}
logStr += '[param:boundary_circle] ';
}
// boundary country
@ -105,6 +121,7 @@ function generateQuery( clean ){
vs.set({
'boundary:country': clean['boundary.country']
});
logStr += '[param:boundary_country] ';
}
// run the address parser
@ -116,6 +133,13 @@ function generateQuery( clean ){
//console.log(JSON.stringify(q, null, 2));
if (q !== undefined) {
logger.info(logStr);
}
else {
logger.info('[parser:libpostal] query type not supported');
}
return q;
}

27
query/search_original.js

@ -1,7 +1,10 @@
var peliasQuery = require('pelias-query'),
defaults = require('./search_defaults'),
textParser = require('./text_parser_addressit'),
check = require('check-types');
'use strict';
const peliasQuery = require('pelias-query');
const defaults = require('./search_defaults');
const textParser = require('./text_parser_addressit');
const check = require('check-types');
const logger = require('pelias-logger').get('api');
var placeTypes = require('../helper/placeTypes');
@ -56,23 +59,33 @@ function generateQuery( clean ){
var vs = new peliasQuery.Vars( defaults );
let logStr = '[query:search] [parser:addressit] ';
// input text
vs.var( 'input:name', clean.text );
// sources
if( check.array(clean.sources) && clean.sources.length ) {
vs.var( 'sources', clean.sources);
logStr += '[param:sources] ';
}
// layers
if( check.array(clean.layers) && clean.layers.length ) {
vs.var( 'layers', clean.layers);
logStr += '[param:layers] ';
}
// categories
if (clean.categories) {
vs.var('input:categories', clean.categories);
logStr += '[param:categories] ';
}
// size
if( clean.querySize ) {
vs.var( 'size', clean.querySize );
logStr += '[param:size] ';
}
// focus point
@ -82,6 +95,7 @@ function generateQuery( clean ){
'focus:point:lat': clean['focus.point.lat'],
'focus:point:lon': clean['focus.point.lon']
});
logStr += '[param:focus_point] ';
}
// boundary rect
@ -95,6 +109,7 @@ function generateQuery( clean ){
'boundary:rect:bottom': clean['boundary.rect.min_lat'],
'boundary:rect:left': clean['boundary.rect.min_lon']
});
logStr += '[param:boundary_rect] ';
}
// boundary circle
@ -111,6 +126,7 @@ function generateQuery( clean ){
'boundary:circle:radius': Math.round( clean['boundary.circle.radius'] ) + 'km'
});
}
logStr += '[param:boundary_circle] ';
}
// boundary country
@ -118,6 +134,7 @@ function generateQuery( clean ){
vs.set({
'boundary:country': clean['boundary.country']
});
logStr += '[param:boundary_country] ';
}
// run the address parser
@ -125,6 +142,8 @@ function generateQuery( clean ){
textParser( clean.parsed_text, vs );
}
logger.info(logStr);
return {
type: 'original',
body: query.render(vs)

Loading…
Cancel
Save