Browse Source

refactor leftovers for clarity

pull/229/head
Peter Johnson 9 years ago
parent
commit
34cd25a023
  1. 10
      query/search.js

10
query/search.js

@ -6,7 +6,6 @@ var peliasQuery = require('pelias-query'),
//------------------------------ //------------------------------
// general-purpose search query // general-purpose search query
//------------------------------ //------------------------------
var query = new peliasQuery.layout.FilteredBooleanQuery(); var query = new peliasQuery.layout.FilteredBooleanQuery();
// mandatory matches // mandatory matches
@ -127,18 +126,17 @@ function generate( clean ){
// @todo: clean up this code // @todo: clean up this code
// a concept called 'leftovers' which is just 'admin_parts' plus 'regions'. // a concept called 'leftovers' which is just 'admin_parts' plus 'regions'.
var leftovers = []; var leftoversString = '';
if( clean.parsed_input.hasOwnProperty('admin_parts') ){ 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') ){ 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 // if we have 'leftovers' then assign them to any fields which
// currently don't have a value assigned. // currently don't have a value assigned.
if( leftovers.length ){ if( leftoversString.length ){
var leftoversString = leftovers.join(' ');
var unmatchedAdminFields = adminFields.slice(); var unmatchedAdminFields = adminFields.slice();
// cycle through fields and set fields which // cycle through fields and set fields which

Loading…
Cancel
Save