Drop country tokens that do not match the country code list
early. Remove in turn the special country code check for
structured phrases. It is sufficient to do this during
word list building.
// Revisit searches, drop bad searches and give penalty to unlikely combinations.
$aGroupedSearches = array();
foreach ($aSearches as $oSearch) {
// Revisit searches, drop bad searches and give penalty to unlikely combinations.
$aGroupedSearches = array();
foreach ($aSearches as $oSearch) {
- if (!$oSearch->isValidSearch($this->aCountryCodes)) {
+ if (!$oSearch->isValidSearch()) {
);
$aWordFrequencyScores = array();
foreach ($aDatabaseWords as $aToken) {
);
$aWordFrequencyScores = array();
foreach ($aDatabaseWords as $aToken) {
- // Very special case - require 2 letter country param to match the country code found
- if ($bStructuredPhrases && $aToken['country_code'] && !empty($this->aStructuredQuery['country'])
- && strlen($this->aStructuredQuery['country']) == 2 && strtolower($this->aStructuredQuery['country']) != $aToken['country_code']
+ // Filter country tokens that do not match restricted countries.
+ if ($this->aCountryCodes
+ && $aToken['country_code']
+ && !in_array($aToken['country_code'], $this->aCountryCodes)
/**
* Check if the combination of parameters is sensible.
*
/**
* Check if the combination of parameters is sensible.
*
- * @param string[] $aCountryCodes List of country codes.
- *
* @return bool True, if the search looks valid.
*/
* @return bool True, if the search looks valid.
*/
- public function isValidSearch(&$aCountryCodes)
+ public function isValidSearch()
{
if (!sizeof($this->aName)) {
if ($this->sHouseNumber) {
return false;
}
{
if (!sizeof($this->aName)) {
if ($this->sHouseNumber) {
return false;
}
- }
- if ($aCountryCodes
- && $this->sCountryCode
- && !in_array($this->sCountryCode, $aCountryCodes)
- ) {
- return false;
+ if (!$this->sClass && !$this->sCountryCode) {
+ return false;
+ }
$oSearch->setPoiSearch($iOp, $aSearchTerm['class'], $aSearchTerm['type']);
$aNewSearches[] = $oSearch;
}
$oSearch->setPoiSearch($iOp, $aSearchTerm['class'], $aSearchTerm['type']);
$aNewSearches[] = $oSearch;
}
- } elseif (isset($aSearchTerm['word_id']) && $aSearchTerm['word_id']) {
+ } elseif (isset($aSearchTerm['word_id'])
+ && $aSearchTerm['word_id']
+ && $sPhraseType != 'country'
+ ) {
$iWordID = $aSearchTerm['word_id'];
if (sizeof($this->aName)) {
if (($sPhraseType == '' || !$bFirstPhrase)
$iWordID = $aSearchTerm['word_id'];
if (sizeof($this->aName)) {
if (($sPhraseType == '' || !$bFirstPhrase)