mirror of https://github.com/pelias/api.git
Peter Johnson @insertcoffee
10 years ago
2 changed files with 42 additions and 36 deletions
@ -1,31 +1,15 @@
|
||||
var logger = require('../src/logger'); |
||||
|
||||
// Build pelias search query
|
||||
var logger = require('../src/logger'), |
||||
queries = require('geopipes-elasticsearch-backend').queries; |
||||
|
||||
function generate( params ){ |
||||
|
||||
var cmd = { |
||||
"query":{ |
||||
"filtered" : { |
||||
"query" : { |
||||
"match_all" : {} |
||||
}, |
||||
"filter" : { |
||||
"geo_distance" : { |
||||
"distance" : "1km", |
||||
"center_point" : { |
||||
"lat": params.lat, |
||||
"lon": params.lon |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
"size": 1 |
||||
var centroid = { |
||||
lat: params.lat, |
||||
lon: params.lon |
||||
}; |
||||
|
||||
// logger.log( 'cmd', JSON.stringify( cmd, null, 2 ) );
|
||||
return cmd; |
||||
|
||||
return queries.distance( centroid, { size: 1 } ); |
||||
} |
||||
|
||||
module.exports = generate; |
Loading…
Reference in new issue