- $aSearch['aAddress'] = array_merge($aSearch['aAddress'], $aSearch['aName']);
- $aSearch['aName'] = array();
- $aSearch['aName'][$aSearchTerm['word_id']] = $aSearchTerm['word_id'];
+ // If we already have a name try putting the postcode first
+ if (sizeof($aSearch['aName']))
+ {
+ $aNewSearch = $aSearch;
+ $aNewSearch['aAddress'] = array_merge($aNewSearch['aAddress'], $aNewSearch['aName']);
+ $aNewSearch['aName'] = array();
+ $aNewSearch['aName'][$aSearchTerm['word_id']] = $aSearchTerm['word_id'];
+ if ($aSearch['iSearchRank'] < $iMaxRank) $aNewWordsetSearches[] = $aNewSearch;
+ }
+
+ if (sizeof($aSearch['aName']))
+ {
+ if ((!$bStructuredPhrases || $iPhrase > 0) && $sPhraseType != 'country' && (!isset($aValidTokens[$sToken]) || strlen($sToken) < 4 || strpos($sToken, ' ') !== false))
+ {
+ $aSearch['aAddress'][$aSearchTerm['word_id']] = $aSearchTerm['word_id'];
+ }
+ else
+ {
+ $aCurrentSearch['aFullNameAddress'][$aSearchTerm['word_id']] = $aSearchTerm['word_id'];
+ $aSearch['iSearchRank'] += 1000; // skip;
+ }
+ }
+ else
+ {
+ $aSearch['aName'][$aSearchTerm['word_id']] = $aSearchTerm['word_id'];
+ //$aSearch['iNamePhrase'] = $iPhrase;
+ }
+ if ($aSearch['iSearchRank'] < $iMaxRank) $aNewWordsetSearches[] = $aSearch;