]> git.openstreetmap.org Git - nominatim.git/commitdiff
Switch to sql.gz format for wikipedia data
authorSarah Hoffmann <lonvia@denofr.de>
Sun, 17 Nov 2019 09:09:31 +0000 (10:09 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Sun, 17 Nov 2019 09:09:31 +0000 (10:09 +0100)
The dump import is no longer needed.

docs/admin/Import-and-Update.md
lib/setup/SetupClass.php

index a38d8eea22cbf2dce1fa653cda6890a5e6e07b56..246fcddab1ad615cb127af75317de3579505c762 100644 (file)
@@ -41,10 +41,9 @@ but it will improve the quality of the results if this is installed.
 This data is available as a binary download:
 
     cd $NOMINATIM_SOURCE_DIR/data
-    wget https://www.nominatim.org/data/wikimedia_importance.sql.gz
+    wget https://www.nominatim.org/data/wikimedia-importance.sql.gz
 
-The file is about 1GB and it adds around 10GB to the install
-size of Nominatim. They also increase the install time by an hour or so.
+The file is about 400MB and adds around 4GB to Nominatim database.
 
 *NOTE:* if you forgot to download the wikipedia rankings, you can also add
 them after the import by running `./utils/setup.php --import-wikipedia-articles`
index c1c15d9a5f846384db100800b75ccb6fadd937fd..1c4547e3a9c6f85fd689568234758c2f7121fc13 100755 (executable)
@@ -323,10 +323,12 @@ class SetupFunctions
 
     public function importWikipediaArticles()
     {
-        $sWikiArticlesFile = CONST_Wikipedia_Data_Path.'/wikimedia_importance.sql.gz';
+        $this->pgExec('DROP TABLE wikipedia_article');
+        $this->pgExec('DROP TABLE wikipedia_redirect');
+        $sWikiArticlesFile = CONST_Wikipedia_Data_Path.'/wikimedia-importance.sql.gz';
         if (file_exists($sWikiArticlesFile)) {
             info('Importing wikipedia articles and redirects');
-            $this->pgsqlRunDropAndRestore($sWikiArticlesFile);
+            $this->pgsqlRunScriptFile($sWikiArticlesFile);
         } else {
             warn('wikipedia importance dump file not found - places will have default importance');
         }
@@ -737,25 +739,6 @@ class SetupFunctions
         }
     }
 
-    private function pgsqlRunDropAndRestore($sDumpFile)
-    {
-        $sCMD = 'pg_restore'
-            .' -p '.escapeshellarg($this->aDSNInfo['port'])
-            .' -d '.escapeshellarg($this->aDSNInfo['database'])
-            .' --no-owner -Fc --clean '.escapeshellarg($sDumpFile);
-        if ($this->oDB->getPostgresVersion() >= 9.04) {
-            $sCMD .= ' --if-exists';
-        }
-        if (isset($this->aDSNInfo['hostspec'])) {
-            $sCMD .= ' -h '.escapeshellarg($this->aDSNInfo['hostspec']);
-        }
-        if (isset($this->aDSNInfo['username'])) {
-            $sCMD .= ' -U '.escapeshellarg($this->aDSNInfo['username']);
-        }
-
-        $this->runWithPgEnv($sCMD);
-    }
-
     private function pgsqlRunScript($sScript, $bfatal = true)
     {
         runSQLScript(