You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

46 lines
1.0 KiB

var logger = require('../src/logger');
// Build pelias search query
function generate( params ){
var cmd = {
"query":{
"query_string" : {
"query": params.input,
"fields": ['name.default'],
"default_operator": 'OR'
}
},
"filter": {
"geo_bounding_box": {
"center_point": {
"top_left": {
"lat": params.bbox.top_left.lat,
"lon": params.bbox.top_left.lon
},
"bottom_right": {
"lat": params.bbox.bottom_right.lat,
"lon": params.bbox.bottom_right.lon
}
}
}
},
"sort" : [{
"_geo_distance" : {
"center_point" : {
"lat": params.lat,
"lon": params.lon
},
"order": 'asc',
"unit": 'km'
}
}],
"size": 30
};
logger.log( 'cmd', JSON.stringify( cmd, null, 2 ) );
return cmd;
}
module.exports = generate;