diff --git a/controller/search.js b/controller/search.js index 4adaf31d..a564e7b4 100644 --- a/controller/search.js +++ b/controller/search.js @@ -11,7 +11,6 @@ function setup( backend, query ){ // do not run controller when a request // validation error has occurred. if( req.errors && req.errors.length ){ - delete req.clean.type; //to declutter output return next(); } @@ -25,12 +24,9 @@ function setup( backend, query ){ body: query( req.clean ) }; - // set the Elasticsearch types to filter by, - // and remove the property from clean so the API - // response output is cleaner - if( req.clean.hasOwnProperty('type') ){ - cmd.type = req.clean.type; - delete req.clean.type; + // use layers field for filtering by type + if( req.clean.hasOwnProperty('layers') ){ + cmd.type = req.clean.layers; } logger.debug( '[ES req]', JSON.stringify(cmd) ); diff --git a/middleware/_types.js b/middleware/_types.js deleted file mode 100644 index ccabdab9..00000000 --- a/middleware/_types.js +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Take the layers specified by the layers parameter and use them to set the - * list of Elasticsearch types to filter. - * - * This has to be done outside the layers sanitizer since it doesn't know that - * the layers property is eventualy used to choose the _type. - */ -function middleware(req, res, next) { - req.clean = req.clean || {}; - - if (req.clean.hasOwnProperty('layers')) { - req.clean.type = req.clean.layers; - } - - next(); -} - -module.exports = middleware; diff --git a/routes/v1.js b/routes/v1.js index 49c9ea4c..00c99aa5 100644 --- a/routes/v1.js +++ b/routes/v1.js @@ -12,7 +12,6 @@ var sanitisers = { /** ----------------------- middleware ------------------------ **/ var middleware = { - types: require('../middleware/_types'), calcSize: require('../middleware/sizeCalculator') }; @@ -59,7 +58,6 @@ function addRoutes(app, peliasConfig) { ]), search: createRouter([ sanitisers.search.middleware, - middleware.types, middleware.calcSize(), controllers.search(), postProc.distances('focus.point.'), @@ -72,7 +70,6 @@ function addRoutes(app, peliasConfig) { ]), autocomplete: createRouter([ sanitisers.autocomplete.middleware, - middleware.types, controllers.search(null, require('../query/autocomplete')), postProc.distances('focus.point.'), postProc.confidenceScores(peliasConfig), @@ -84,7 +81,6 @@ function addRoutes(app, peliasConfig) { ]), reverse: createRouter([ sanitisers.reverse.middleware, - middleware.types, middleware.calcSize(), controllers.search(undefined, reverseQuery), postProc.distances('point.'),