3 require_once(CONST_LibDir.'/init-cmd.php');
13 $print_success = function ($message = 'OK') use ($term_colors) {
14 echo $term_colors['green'].$message.$term_colors['normal']."\n";
17 $print_fail = function ($message = 'Failed') use ($term_colors) {
18 echo $term_colors['red'].$message.$term_colors['normal']."\n";
22 $oDB = new Nominatim\DB;
25 function isReverseOnlyInstallation()
28 return !$oDB->tableExists('search_name');
32 echo 'Checking database got created ... ';
33 if ($oDB->checkConnection()) {
39 * Is the database server started?
40 * Check the NOMINATIM_DATABASE_DSN variable in your local .env
41 * Try connecting to the database with the same settings
48 echo 'Checking nominatim.so module installed ... ';
49 $sStandardWord = $oDB->getOne("SELECT make_standard_name('a')");
50 if ($sStandardWord === 'a') {
55 The Postgresql extension nominatim.so was not found in the database.
57 * Check the output of the CMmake/make installation step
58 * Does nominatim.so exist?
59 * Does nominatim.so exist on the database server?
60 * Can nominatim.so be accessed by the database user?
66 echo 'Checking place table ... ';
67 if ($oDB->tableExists('place')) {
72 * The import didn't finish.
74 * Check the output of the utils/setup.php you ran.
75 Usually the osm2pgsql step failed. Check for errors related to
76 * the file you imported not containing any places
79 * osm2pgsql killed by other scripts, for consuming to much memory
87 echo 'Checking indexing status ... ';
88 $iUnindexed = $oDB->getOne('SELECT count(*) FROM placex WHERE indexed_status > 0');
89 if ($iUnindexed == 0) {
94 The indexing didn't finish. There is still $iUnindexed places. See the
95 question 'Can a stopped/killed import process be resumed?' in the
96 troubleshooting guide.
102 echo "Search index creation\n";
103 $aExpectedIndices = array(
104 // sql/indices.src.sql
106 'idx_place_addressline_address_place_id',
107 'idx_placex_rank_search',
108 'idx_placex_rank_address',
109 'idx_placex_pendingsector',
110 'idx_placex_parent_place_id',
111 'idx_placex_geometry_reverse_lookuppolygon',
112 'idx_placex_geometry_reverse_placenode',
113 'idx_location_area_country_place_id',
114 'idx_osmline_parent_place_id',
115 'idx_osmline_parent_osm_id',
116 'idx_place_osm_unique',
118 'idx_postcode_postcode'
120 if (!isReverseOnlyInstallation()) {
121 $aExpectedIndices = array_merge($aExpectedIndices, array(
122 // sql/indices_search.src.sql
123 'idx_search_name_nameaddress_vector',
124 'idx_search_name_name_vector',
125 'idx_search_name_centroid'
129 foreach ($aExpectedIndices as $sExpectedIndex) {
130 echo "Checking index $sExpectedIndex ... ";
131 if ($oDB->indexExists($sExpectedIndex)) {
137 * Run './utils/setup.php --create-search-indices --ignore-errors' to
138 create missing indices.
145 echo 'Checking search indices are valid ... ';
148 FROM pg_class, pg_index
149 WHERE pg_index.indisvalid = false
150 AND pg_index.indexrelid = pg_class.oid;
152 $aInvalid = $oDB->getCol($sSQL);
153 if (empty($aInvalid)) {
158 At least one index is invalid. That can happen, e.g. when index creation was
159 disrupted and later restarted. You should delete the affected indices and
160 run the index stage of setup again.
161 See the question 'Can a stopped/killed import process be resumed?' in the
162 troubleshooting guide.
165 echo join(', ', $aInvalid) . "\n";
171 if (getSettingBool('USE_US_TIGER_DATA')) {
172 echo 'Checking TIGER table exists ... ';
173 if ($oDB->tableExists('location_property_tiger')) {
178 Table 'location_property_tiger' does not exist. Run the TIGER data