From e26da936b319906a8f2798f9741cfd558c31e23b Mon Sep 17 00:00:00 2001 From: Brian Quinion Date: Tue, 11 Jun 2013 17:13:37 +0100 Subject: [PATCH] recheck the rank limits before dropping out of the search loop - otherwise we can drop out too soon --- website/search.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/website/search.php b/website/search.php index 76daa98c..a29cb0cb 100755 --- a/website/search.php +++ b/website/search.php @@ -931,7 +931,9 @@ if ($sViewboxLargeSQL) $sImportanceSQL .= " * case when ST_Contains($sViewboxLargeSQL, centroid) THEN 1 ELSE 0.5 END"; $aOrder[] = "$sImportanceSQL DESC"; if (sizeof($aSearch['aFullNameAddress'])) + { $aOrder[] = '(select count(*) from (select unnest(ARRAY['.join($aSearch['aFullNameAddress'],",").']) INTERSECT select unnest(nameaddress_vector))s) DESC'; + } if (sizeof($aTerms)) { @@ -1148,6 +1150,19 @@ if ($iQueryLoop > 20) break; } + if (isset($aResultPlaceIDs) && sizeof($aResultPlaceIDs) && ($iMinAddressRank != 0 || $iMaxAddressRank != 30)) + { + // Need to verify passes rank limits before dropping out of the loop (yuk!) + $sSQL = "select place_id from placex where place_id in (".join(',',$aResultPlaceIDs).") "; + $sSQL .= "and (placex.rank_address between $iMinAddressRank and $iMaxAddressRank "; + if (14 >= $iMinAddressRank && 14 <= $iMaxAddressRank) $sSQL .= " OR (extratags->'place') = 'city'"; + if ($aAddressRankList) $sSQL .= " OR placex.rank_address in (".join(',',$aAddressRankList).")"; + $sSQL .= ") "; + if (CONST_Debug) var_dump($sSQL); + $aResultPlaceIDs = $oDB->getCol($sSQL); + } + + //exit; if (isset($aResultPlaceIDs) && sizeof($aResultPlaceIDs)) break; if ($iGroupLoop > 4) break; -- 2.39.5