mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-03-13 22:34:07 +00:00
Make deduplicate work again. Only currently support 9.3 due to new postgresql functions added.
This commit is contained in:
@@ -254,6 +254,13 @@
|
|||||||
|
|
||||||
if ($aResult['deduplicate'])
|
if ($aResult['deduplicate'])
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$pgver = (float) CONST_Postgresql_Version;
|
||||||
|
if ($pgver < 9.3) {
|
||||||
|
echo "ERROR: deduplicate is only currently supported in postgresql 9.3";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
$oDB =& getDB();
|
$oDB =& getDB();
|
||||||
$sSQL = 'select partition from country_name order by country_code';
|
$sSQL = 'select partition from country_name order by country_code';
|
||||||
$aPartitions = $oDB->getCol($sSQL);
|
$aPartitions = $oDB->getCol($sSQL);
|
||||||
@@ -283,8 +290,8 @@
|
|||||||
foreach($aTokenSet as $aRemove)
|
foreach($aTokenSet as $aRemove)
|
||||||
{
|
{
|
||||||
$sSQL = "update search_name set";
|
$sSQL = "update search_name set";
|
||||||
$sSQL .= " name_vector = (name_vector - ".$aRemove['word_id'].")+".$iKeepID.",";
|
$sSQL .= " name_vector = array_replace(name_vector,".$aRemove['word_id'].",".$iKeepID."),";
|
||||||
$sSQL .= " nameaddress_vector = (nameaddress_vector - ".$aRemove['word_id'].")+".$iKeepID;
|
$sSQL .= " nameaddress_vector = array_replace(nameaddress_vector,".$aRemove['word_id'].",".$iKeepID.")";
|
||||||
$sSQL .= " where name_vector @> ARRAY[".$aRemove['word_id']."]";
|
$sSQL .= " where name_vector @> ARRAY[".$aRemove['word_id']."]";
|
||||||
$x = $oDB->query($sSQL);
|
$x = $oDB->query($sSQL);
|
||||||
if (PEAR::isError($x))
|
if (PEAR::isError($x))
|
||||||
@@ -294,7 +301,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$sSQL = "update search_name set";
|
$sSQL = "update search_name set";
|
||||||
$sSQL .= " nameaddress_vector = (nameaddress_vector - ".$aRemove['word_id'].")+".$iKeepID;
|
$sSQL .= " nameaddress_vector = array_replace(nameaddress_vector,".$aRemove['word_id'].",".$iKeepID.")";
|
||||||
$sSQL .= " where nameaddress_vector @> ARRAY[".$aRemove['word_id']."]";
|
$sSQL .= " where nameaddress_vector @> ARRAY[".$aRemove['word_id']."]";
|
||||||
$x = $oDB->query($sSQL);
|
$x = $oDB->query($sSQL);
|
||||||
if (PEAR::isError($x))
|
if (PEAR::isError($x))
|
||||||
@@ -304,7 +311,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$sSQL = "update location_area_country set";
|
$sSQL = "update location_area_country set";
|
||||||
$sSQL .= " keywords = (keywords - ".$aRemove['word_id'].")+".$iKeepID;
|
$sSQL .= " keywords = array_replace(keywords,".$aRemove['word_id'].",".$iKeepID.")";
|
||||||
$sSQL .= " where keywords @> ARRAY[".$aRemove['word_id']."]";
|
$sSQL .= " where keywords @> ARRAY[".$aRemove['word_id']."]";
|
||||||
$x = $oDB->query($sSQL);
|
$x = $oDB->query($sSQL);
|
||||||
if (PEAR::isError($x))
|
if (PEAR::isError($x))
|
||||||
@@ -316,8 +323,7 @@
|
|||||||
foreach ($aPartitions as $sPartition)
|
foreach ($aPartitions as $sPartition)
|
||||||
{
|
{
|
||||||
$sSQL = "update search_name_".$sPartition." set";
|
$sSQL = "update search_name_".$sPartition." set";
|
||||||
$sSQL .= " name_vector = (name_vector - ".$aRemove['word_id'].")+".$iKeepID.",";
|
$sSQL .= " name_vector = array_replace(name_vector,".$aRemove['word_id'].",".$iKeepID.")";
|
||||||
$sSQL .= " nameaddress_vector = (nameaddress_vector - ".$aRemove['word_id'].")+".$iKeepID;
|
|
||||||
$sSQL .= " where name_vector @> ARRAY[".$aRemove['word_id']."]";
|
$sSQL .= " where name_vector @> ARRAY[".$aRemove['word_id']."]";
|
||||||
$x = $oDB->query($sSQL);
|
$x = $oDB->query($sSQL);
|
||||||
if (PEAR::isError($x))
|
if (PEAR::isError($x))
|
||||||
@@ -326,18 +332,8 @@
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sSQL = "update search_name_".$sPartition." set";
|
|
||||||
$sSQL .= " nameaddress_vector = (nameaddress_vector - ".$aRemove['word_id'].")+".$iKeepID;
|
|
||||||
$sSQL .= " where nameaddress_vector @> ARRAY[".$aRemove['word_id']."]";
|
|
||||||
$x = $oDB->query($sSQL);
|
|
||||||
if (PEAR::isError($x))
|
|
||||||
{
|
|
||||||
var_dump($x);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$sSQL = "update location_area_country set";
|
$sSQL = "update location_area_country set";
|
||||||
$sSQL .= " keywords = (keywords - ".$aRemove['word_id'].")+".$iKeepID;
|
$sSQL .= " keywords = array_replace(keywords,".$aRemove['word_id'].",".$iKeepID.")";
|
||||||
$sSQL .= " where keywords @> ARRAY[".$aRemove['word_id']."]";
|
$sSQL .= " where keywords @> ARRAY[".$aRemove['word_id']."]";
|
||||||
$x = $oDB->query($sSQL);
|
$x = $oDB->query($sSQL);
|
||||||
if (PEAR::isError($x))
|
if (PEAR::isError($x))
|
||||||
|
|||||||
Reference in New Issue
Block a user