diff --git a/query/search.js b/query/search.js index 3b368f50..ce3ac639 100644 --- a/query/search.js +++ b/query/search.js @@ -135,10 +135,7 @@ function getQuery(vs) { logger.info(`[query:search] [search_input_type:${determineQueryType(vs)}]`); - if (hasStreet(vs) || - isCityStateOnlyWithOptionalCountry(vs) || - isCityCountryOnly(vs) || - isPostalCodeOnly(vs)) { + if (hasStreet(vs) || isPostalCodeOnly(vs)) { return { type: 'fallback', body: fallbackQuery.render(vs) @@ -162,7 +159,8 @@ function determineQueryType(vs) { return 'venue'; } else if (['neighbourhood', 'borough', 'postcode', 'county', 'region','country'].some( - (layer)=> { return vs.isset(`input:${layer}`);})) { + layer => vs.isset(`input:${layer}`) + )) { return 'admin'; } return 'other'; @@ -172,37 +170,8 @@ function hasStreet(vs) { return vs.isset('input:street'); } -function isCityStateOnlyWithOptionalCountry(vs) { - var isSet = (layer) => { - return vs.isset(`input:${layer}`); - }; - - var allowedFields = ['locality', 'region']; - var disallowedFields = ['query', 'category', 'housenumber', 'street', - 'neighbourhood', 'borough', 'postcode', 'county']; - - return allowedFields.every(isSet) && !disallowedFields.some(isSet); - -} - -function isCityCountryOnly(vs) { - var isSet = (layer) => { - return vs.isset(`input:${layer}`); - }; - - var allowedFields = ['locality', 'country']; - var disallowedFields = ['query', 'category', 'housenumber', 'street', - 'neighbourhood', 'borough', 'postcode', 'county', 'region']; - - return allowedFields.every(isSet) && - !disallowedFields.some(isSet); - -} - function isPostalCodeOnly(vs) { - var isSet = (layer) => { - return vs.isset(`input:${layer}`); - }; + var isSet = layer => vs.isset(`input:${layer}`); var allowedFields = ['postcode']; var disallowedFields = ['query', 'category', 'housenumber', 'street', diff --git a/test/unit/query/search.js b/test/unit/query/search.js index aa582082..c97fb876 100644 --- a/test/unit/query/search.js +++ b/test/unit/query/search.js @@ -284,7 +284,7 @@ module.exports.tests.city_state = function(test, common) { var query = generate(clean); - t.notEqual(query, undefined, 'should not have returned undefined'); + t.equal(query, undefined, 'should have returned undefined'); t.end(); }); @@ -300,7 +300,7 @@ module.exports.tests.city_state = function(test, common) { var query = generate(clean); - t.notEqual(query, undefined, 'should not have returned undefined'); + t.equal(query, undefined, 'should have returned undefined'); t.end(); }); @@ -458,7 +458,7 @@ module.exports.tests.city_country = function(test, common) { var query = generate(clean); - t.notEqual(query, undefined, 'should not have returned undefined'); + t.equal(query, undefined, 'should have returned undefined'); t.end(); }); @@ -621,7 +621,6 @@ module.exports.tests.city_country = function(test, common) { t.end(); }); - }; module.exports.all = function (tape, common) {