From 6b29c5bbfe2b6372a92c61ca619d24b65c45be3c Mon Sep 17 00:00:00 2001 From: Harish Krishna Date: Mon, 13 Oct 2014 12:14:14 -0400 Subject: [PATCH 1/3] adding 'aliases' - 'poi' & 'admin' for the layers param. --- sanitiser/_layers.js | 25 ++++++++++++++++-- test/unit/sanitiser/sanitise.js | 46 ++++++++++++++++++++++++++++++++- 2 files changed, 68 insertions(+), 3 deletions(-) diff --git a/sanitiser/_layers.js b/sanitiser/_layers.js index c4f5d6eb..20e83f78 100644 --- a/sanitiser/_layers.js +++ b/sanitiser/_layers.js @@ -13,17 +13,38 @@ function sanitize( req ){ // which layers to query if('string' === typeof params.layers && params.layers.length){ + + var alias_layers = ['poi', 'admin']; + var alias_indeces = indeces.concat(alias_layers); + var layers = params.layers.split(',').map( function( layer ){ return layer.toLowerCase(); // lowercase inputs }); for( var x=0; x Date: Mon, 13 Oct 2014 12:33:20 -0400 Subject: [PATCH 2/3] adding type --- controller/search.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/controller/search.js b/controller/search.js index fcb12831..1edb3b7a 100644 --- a/controller/search.js +++ b/controller/search.js @@ -12,7 +12,8 @@ function setup( backend, query ){ // backend command var cmd = { index: 'pelias', - body: query( req.clean ) + body: query( req.clean ), + type: req.clean.layers }; // query backend From 0a58bc9fea61381738ea8ea7f0152a47acdf9f26 Mon Sep 17 00:00:00 2001 From: Harish Krishna Date: Mon, 13 Oct 2014 13:40:26 -0400 Subject: [PATCH 3/3] adding type only if clean.layers are not undefined --- controller/search.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/controller/search.js b/controller/search.js index 1edb3b7a..2554de2d 100644 --- a/controller/search.js +++ b/controller/search.js @@ -12,10 +12,12 @@ function setup( backend, query ){ // backend command var cmd = { index: 'pelias', - body: query( req.clean ), - type: req.clean.layers + body: query( req.clean ) }; + if (req.clean.layers) { + cmd.type = req.clean.layers; + } // query backend backend().client.search( cmd, function( err, data ){