|
|
@ -135,10 +135,7 @@ function getQuery(vs) { |
|
|
|
|
|
|
|
|
|
|
|
logger.info(`[query:search] [search_input_type:${determineQueryType(vs)}]`); |
|
|
|
logger.info(`[query:search] [search_input_type:${determineQueryType(vs)}]`); |
|
|
|
|
|
|
|
|
|
|
|
if (hasStreet(vs) || |
|
|
|
if (hasStreet(vs) || isPostalCodeOnly(vs)) { |
|
|
|
isCityStateOnlyWithOptionalCountry(vs) || |
|
|
|
|
|
|
|
isCityCountryOnly(vs) || |
|
|
|
|
|
|
|
isPostalCodeOnly(vs)) { |
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|
type: 'fallback', |
|
|
|
type: 'fallback', |
|
|
|
body: fallbackQuery.render(vs) |
|
|
|
body: fallbackQuery.render(vs) |
|
|
@ -162,7 +159,8 @@ function determineQueryType(vs) { |
|
|
|
return 'venue'; |
|
|
|
return 'venue'; |
|
|
|
} |
|
|
|
} |
|
|
|
else if (['neighbourhood', 'borough', 'postcode', 'county', 'region','country'].some( |
|
|
|
else if (['neighbourhood', 'borough', 'postcode', 'county', 'region','country'].some( |
|
|
|
(layer)=> { return vs.isset(`input:${layer}`);})) { |
|
|
|
layer => vs.isset(`input:${layer}`) |
|
|
|
|
|
|
|
)) { |
|
|
|
return 'admin'; |
|
|
|
return 'admin'; |
|
|
|
} |
|
|
|
} |
|
|
|
return 'other'; |
|
|
|
return 'other'; |
|
|
@ -172,37 +170,8 @@ function hasStreet(vs) { |
|
|
|
return vs.isset('input:street'); |
|
|
|
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) { |
|
|
|
function isPostalCodeOnly(vs) { |
|
|
|
var isSet = (layer) => { |
|
|
|
var isSet = layer => vs.isset(`input:${layer}`); |
|
|
|
return vs.isset(`input:${layer}`); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var allowedFields = ['postcode']; |
|
|
|
var allowedFields = ['postcode']; |
|
|
|
var disallowedFields = ['query', 'category', 'housenumber', 'street', |
|
|
|
var disallowedFields = ['query', 'category', 'housenumber', 'street', |
|
|
|