From 63c8eef0df34c423f8712d4fd385a952d4f51e91 Mon Sep 17 00:00:00 2001 From: Stephen Hess Date: Thu, 13 Jul 2017 18:08:19 -0400 Subject: [PATCH] added libpostal as controller into v1 /search flow --- routes/v1.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/routes/v1.js b/routes/v1.js index 5c8c82be..6ad31202 100644 --- a/routes/v1.js +++ b/routes/v1.js @@ -28,6 +28,7 @@ var middleware = { var controllers = { coarse_reverse: require('../controller/coarse_reverse'), mdToHTML: require('../controller/markdownToHtml'), + libpostal: require('../controller/libpostal'), place: require('../controller/place'), placeholder: require('../controller/placeholder'), search: require('../controller/search'), @@ -116,6 +117,11 @@ function addRoutes(app, peliasConfig) { isPipServiceEnabled, not(hasRequestErrors), not(hasResponseData) ); + const libpostalShouldExecute = all( + not(hasRequestErrors), + not(isRequestSourcesOnlyWhosOnFirst) + ); + // execute placeholder if libpostal only parsed as admin-only and needs to // be geodisambiguated const placeholderGeodisambiguationShouldExecute = all( @@ -220,6 +226,7 @@ function addRoutes(app, peliasConfig) { sanitizers.search.middleware(peliasConfig.api), middleware.requestLanguage, middleware.calcSize(), + controllers.libpostal(libpostalShouldExecute), controllers.placeholder(placeholderService, geometricFiltersApply, placeholderGeodisambiguationShouldExecute), controllers.placeholder(placeholderService, geometricFiltersDontApply, placeholderIdsLookupShouldExecute), controllers.search_with_ids(peliasConfig.api, esclient, queries.address_using_ids, searchWithIdsShouldExecute),