diff --git a/controller/suggest.js b/controller/suggest.js index 8e792ff8..e163789c 100644 --- a/controller/suggest.js +++ b/controller/suggest.js @@ -41,11 +41,19 @@ function setup( backend, query ){ poi: function(callback){ cmd.body = query_poi( req.clean ); query_backend(cmd, callback); + }, + poi3: function(callback){ + cmd.body = query_poi( req.clean, 3 ); + query_backend(cmd, callback); + }, + poi1: function(callback){ + cmd.body = query_poi( req.clean, 1 ); + query_backend(cmd, callback); } }, function(err, results) { - // results is now equals to: {admin: docs, poi: docs} - var combined = results.poi.slice(0, 3).concat(results.admin); + // results is now equals to: {admin: docs, poi: docs, poi1: docs, poi3: docs} + var combined = results.poi.concat(results.admin).concat(results.poi1).concat(results.poi3); // convert docs to geojson var geojson = geojsonify( combined ); diff --git a/query/suggest_poi.js b/query/suggest_poi.js index ba086f88..29f2f0b3 100644 --- a/query/suggest_poi.js +++ b/query/suggest_poi.js @@ -2,7 +2,7 @@ var logger = require('../src/logger'); // Build pelias suggest query -function generate( params ){ +function generate( params, precision ){ var getPrecision = function(zoom) { switch (true) { @@ -29,7 +29,7 @@ function generate( params ){ 'dataset': params.layers, 'location': { 'value': [ params.lon, params.lat ], - 'precision': getPrecision(params.zoom) + 'precision': precision || getPrecision(params.zoom) } } }