From: Sarah Hoffmann Date: Fri, 18 Aug 2017 19:34:52 +0000 (+0200) Subject: throw away searches with two postcodes X-Git-Tag: v3.1.0~88^2~5 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/67bb885900b61e2c128c64a4067db1d3a0e93625?hp=e55ac77c9441359a44e5c4d464353a7970a648c7 throw away searches with two postcodes --- diff --git a/lib/Geocode.php b/lib/Geocode.php index ae6f9cfb..01abc43c 100644 --- a/lib/Geocode.php +++ b/lib/Geocode.php @@ -751,10 +751,11 @@ class Geocode } } elseif ($sPhraseType == 'postalcode' || ($aSearchTerm['class'] == 'place' && $aSearchTerm['type'] == 'postcode')) { // We need to try the case where the postal code is the primary element (i.e. no way to tell if it is (postalcode, city) OR (city, postalcode) so try both - if (isset($aSearchTerm['word_id']) && $aSearchTerm['word_id'] && strpos($sNormQuery, $this->normTerm($aSearchTerm['word'])) !== false) { + if ($aSearch['sPostcode'] === '' && + isset($aSearchTerm['word_id']) && $aSearchTerm['word_id'] && strpos($sNormQuery, $this->normTerm($aSearchTerm['word'])) !== false) { // If we have structured search or this is the first term, // make the postcode the primary search element. - if ($aSearchTerm['operator'] == '' && ($sPhraseType == 'postalcode' || ($iToken == 0 && $iPhrase == 0))) { + if ($aSearch['sOperator'] === '' && ($sPhraseType == 'postalcode' || ($iToken == 0 && $iPhrase == 0))) { $aNewSearch = $aSearch; $aNewSearch['sOperator'] = 'postcode'; $aNewSearch['aAddress'] = array_merge($aNewSearch['aAddress'], $aNewSearch['aName']); @@ -1207,7 +1208,6 @@ class Geocode ksort($aGroupedSearches); } - if (CONST_Debug) var_Dump($aGroupedSearches); if (CONST_Search_TryDroppedAddressTerms && sizeof($this->aStructuredQuery) > 0) { $aCopyGroupedSearches = $aGroupedSearches; foreach ($aCopyGroupedSearches as $iGroup => $aSearches) {