From 34cd25a023d6133fcdff731725b8b201c14eaf13 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Tue, 8 Sep 2015 19:46:03 +0200 Subject: [PATCH] refactor leftovers for clarity --- query/search.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/query/search.js b/query/search.js index 7a0a3b96..4ba311c9 100644 --- a/query/search.js +++ b/query/search.js @@ -6,7 +6,6 @@ var peliasQuery = require('pelias-query'), //------------------------------ // general-purpose search query //------------------------------ - var query = new peliasQuery.layout.FilteredBooleanQuery(); // mandatory matches @@ -127,18 +126,17 @@ function generate( clean ){ // @todo: clean up this code // a concept called 'leftovers' which is just 'admin_parts' plus 'regions'. - var leftovers = []; + var leftoversString = ''; if( clean.parsed_input.hasOwnProperty('admin_parts') ){ - leftovers.push( clean.parsed_input.admin_parts ); + leftoversString = clean.parsed_input.admin_parts; } else if( clean.parsed_input.hasOwnProperty('regions') ){ - leftovers.push( clean.parsed_input.regions ); + leftoversString = clean.parsed_input.regions.join(' '); } // if we have 'leftovers' then assign them to any fields which // currently don't have a value assigned. - if( leftovers.length ){ - var leftoversString = leftovers.join(' '); + if( leftoversString.length ){ var unmatchedAdminFields = adminFields.slice(); // cycle through fields and set fields which