Mostly minor updates in wording and resource consumption.
@define('CONST_Osm2pgsql_Flatnode_File', '/path/to/flatnode.file');
Replace the second part with a suitable path on your system and make sure
@define('CONST_Osm2pgsql_Flatnode_File', '/path/to/flatnode.file');
Replace the second part with a suitable path on your system and make sure
-the directory exists. There should be at least 64GB of free space.
+the directory exists. There should be at least 75GB of free space.
## Downloading additional data
## Downloading additional data
cd $NOMINATIM_SOURCE_DIR/data
wget https://www.nominatim.org/data/wikimedia-importance.sql.gz
cd $NOMINATIM_SOURCE_DIR/data
wget https://www.nominatim.org/data/wikimedia-importance.sql.gz
-The file is about 400MB and adds around 4GB to Nominatim database.
+The file is about 400MB and adds around 4GB to the Nominatim database.
!!! tip
If you forgot to download the wikipedia rankings, you can also add
!!! tip
If you forgot to download the wikipedia rankings, you can also add
wget https://www.nominatim.org/data/gb_postcode_data.sql.gz
wget https://www.nominatim.org/data/us_postcode_data.sql.gz
wget https://www.nominatim.org/data/gb_postcode_data.sql.gz
wget https://www.nominatim.org/data/us_postcode_data.sql.gz
-## Choosing the Data to Import
+## Choosing the data to import
In its default setup Nominatim is configured to import the full OSM data
set for the entire planet. Such a setup requires a powerful machine with
In its default setup Nominatim is configured to import the full OSM data
set for the entire planet. Such a setup requires a powerful machine with
-If you only need geocoding for a smaller region, then precomputed extracts
+If you only need geocoding for a smaller region, then precomputed OSM extracts
are a good way to reduce the database size and import time.
[Geofabrik](https://download.geofabrik.de) offers extracts for most countries.
They even have daily updates which can be used with the update process described
are a good way to reduce the database size and import time.
[Geofabrik](https://download.geofabrik.de) offers extracts for most countries.
They even have daily updates which can be used with the update process described
+[in the next section](../Update). There are also
[other providers for extracts](https://wiki.openstreetmap.org/wiki/Planet.osm#Downloading).
Please be aware that some extracts are not cut exactly along the country
[other providers for extracts](https://wiki.openstreetmap.org/wiki/Planet.osm#Downloading).
Please be aware that some extracts are not cut exactly along the country
To give you an idea of the impact of using the different styles, the table
below gives rough estimates of the final database size after import of a
To give you an idea of the impact of using the different styles, the table
below gives rough estimates of the final database size after import of a
-2018 planet and after using the `--drop` option. It also shows the time
-needed for the import on a machine with 64GB RAM, 4 CPUS and SSDs. Note that
-the given sizes are just an estimate meant for comparison of style requirements.
-Your planet import is likely to be larger as the OSM data grows with time.
+2020 planet and after using the `--drop` option. It also shows the time
+needed for the import on a machine with 64GB RAM, 4 CPUS and NVME disks.
+Note that the given sizes are just an estimate meant for comparison of
+style requirements. Your planet import is likely to be larger as the
+OSM data grows with time.
style | Import time | DB size | after drop
----------|--------------|------------|------------
style | Import time | DB size | after drop
----------|--------------|------------|------------
-admin | 5h | 190 GB | 20 GB
+admin | 4h | 215 GB | 20 GB
street | 42h | 400 GB | 180 GB
address | 59h | 500 GB | 260 GB
full | 80h | 575 GB | 300 GB
extratags | 80h | 585 GB | 310 GB
street | 42h | 400 GB | 180 GB
address | 59h | 500 GB | 260 GB
full | 80h | 575 GB | 300 GB
extratags | 80h | 585 GB | 310 GB
-You can also customize the styles further. For a description of the
-style format see [the development section](../develop/Import.md).
+You can also customize the styles further.
+A [description of the style format](../develop/Import.md#configuring-the-import)
+can be found in the development section.
## Initial import of the data
## Initial import of the data
First try the import with a small extract, for example from
[Geofabrik](https://download.geofabrik.de).
First try the import with a small extract, for example from
[Geofabrik](https://download.geofabrik.de).
-Download the data to import and load the data with the following command
-from the build directory:
+Download the data to import. Then issue the following command
+from the **build directory** to start the import:
```sh
./utils/setup.php --osm-file <data file> --all 2>&1 | tee setup.log
```
```sh
./utils/setup.php --osm-file <data file> --all 2>&1 | tee setup.log
```
-***Note for full planet imports:*** Even on a perfectly configured machine
-the import of a full planet takes at least 2 days. Once you see messages
+### Notes on full planet imports
+
+Even on a perfectly configured machine
+the import of a full planet takes around 2 days. Once you see messages
with `Rank .. ETA` appear, the indexing process has started. This part takes
the most time. There are 30 ranks to process. Rank 26 and 30 are the most complex.
They take each about a third of the total import time. If you have not reached
with `Rank .. ETA` appear, the indexing process has started. This part takes
the most time. There are 30 ranks to process. Rank 26 and 30 are the most complex.
They take each about a third of the total import time. If you have not reached
### Notes on memory usage
### Notes on memory usage
-In the first step of the import Nominatim uses osm2pgsql to load the OSM data
-into the PostgreSQL database. This step is very demanding in terms of RAM usage.
-osm2pgsql and PostgreSQL are running in parallel at this point. PostgreSQL
-blocks at least the part of RAM that has been configured with the
-`shared_buffers` parameter during [PostgreSQL tuning](Installation#postgresql-tuning)
+In the first step of the import Nominatim uses [osm2pgsql](https://osm2pgsql.org)
+to load the OSM data into the PostgreSQL database. This step is very demanding
+in terms of RAM usage. osm2pgsql and PostgreSQL are running in parallel at
+this point. PostgreSQL blocks at least the part of RAM that has been configured
+with the `shared_buffers` parameter during
+[PostgreSQL tuning](Installation#postgresql-tuning)
and needs some memory on top of that. osm2pgsql needs at least 2GB of RAM for
its internal data structures, potentially more when it has to process very large
relations. In addition it needs to maintain a cache for node locations. The size
and needs some memory on top of that. osm2pgsql needs at least 2GB of RAM for
its internal data structures, potentially more when it has to process very large
relations. In addition it needs to maintain a cache for node locations. The size
by default, so you do not need to configure anything in this case.
For imports without a flatnode file, set `--osm2pgsql-cache` approximately to
by default, so you do not need to configure anything in this case.
For imports without a flatnode file, set `--osm2pgsql-cache` approximately to
-the size of the OSM pbf file (in MB) you are importing. Make sure you leave
-enough RAM for PostgreSQL and osm2pgsql as mentioned above. If the system starts
-swapping or you are getting out-of-memory errors, reduce the cache size or
-even consider using a flatnode file.
+the size of the OSM pbf file you are importing. The size needs to be given in
+MB. Make sure you leave enough RAM for PostgreSQL and osm2pgsql as mentioned
+above. If the system starts swapping or you are getting out-of-memory errors,
+reduce the cache size or even consider using a flatnode file.
### Setting up the website
### Setting up the website
-Run the following command to set up the configuration file for the website
+Run the following command to set up the configuration file for the API frontend
`settings/settings-frontend.php`. These settings are used in website/*.php files.
```sh
`settings/settings-frontend.php`. These settings are used in website/*.php files.
```sh
git clone https://github.com/osm-search/nominatim-ui
git clone https://github.com/osm-search/nominatim-ui
-Adapt the configuration `dist/config.js` to your needs. You need at least
+Copy the example configuration into the right place:
+
+ cd nominatim-ui
+ cp dist/config.example.js dist/config.js
+
+Now adapt the configuration to your needs. You need at least
to change the `Nominatim_API_Endpoint` to point to your Nominatim installation.
Then you can just test it locally by spinning up a webserver in the `dist`
to change the `Nominatim_API_Endpoint` to point to your Nominatim installation.
Then you can just test it locally by spinning up a webserver in the `dist`
-# Determine from the URI and the format parameter aboce if forwarding is needed.
+# Determine from the URI and the format parameter above if forwarding is needed.
map $uri/$format $forward_to_ui {
default 1; # The default is to forward.
~^/ui 0; # If the URI point to the UI already, we are done.
map $uri/$format $forward_to_ui {
default 1; # The default is to forward.
~^/ui 0; # If the URI point to the UI already, we are done.
The following section describes how to keep it up-to-date with Pyosmium.
For a list of other methods see the output of `./utils/update.php --help`.
The following section describes how to keep it up-to-date with Pyosmium.
For a list of other methods see the output of `./utils/update.php --help`.
If you have configured a flatnode file for the import, then you
If you have configured a flatnode file for the import, then you
- need to keep this flatnode file around for updates as well.
+ need to keep this flatnode file around for updates.
#### Installing the newest version of Pyosmium
#### Installing the newest version of Pyosmium
## Prerequisites for testing and documentation
## Prerequisites for testing and documentation
-The Nominatim tests suite consists of behavioural tests (using behave) and
+The Nominatim test suite consists of behavioural tests (using behave) and
unit tests (using PHPUnit). It has the following additional requirements:
* [behave test framework](https://behave.readthedocs.io) >= 1.2.5
unit tests (using PHPUnit). It has the following additional requirements:
* [behave test framework](https://behave.readthedocs.io) >= 1.2.5
Some of the behavioural test expect a test database to be present. You need at
least 2GB RAM and 10GB disk space to create the database.
Some of the behavioural test expect a test database to be present. You need at
least 2GB RAM and 10GB disk space to create the database.
-First create a separate directory for the test DB and Fetch the test planet
+First create a separate directory for the test DB and fetch the test planet
data and the Tiger data for South Dakota:
```
data and the Tiger data for South Dakota:
```
-OSM data is initially imported using osm2pgsql. Nominatim uses its own data
-output style 'gazetteer', which differs from the output style created for
-map rendering.
+OSM data is initially imported using [osm2pgsql](https://osm2pgsql.org).
+Nominatim uses its own data output style 'gazetteer', which differs from the
+output style created for map rendering.
## Search rank
The search rank describes the extent and importance of a place. It is used
## Search rank
The search rank describes the extent and importance of a place. It is used
-when ranking search result. Simply put, if there are two results for a
+when ranking search results. Simply put, if there are two results for a
search query which are otherwise equal, then the result with the _lower_
search rank will be appear higher in the result list.
search query which are otherwise equal, then the result with the _lower_
search rank will be appear higher in the result list.
## PHP Unit Tests (`test/php`)
## PHP Unit Tests (`test/php`)
-Unit tests can be found in the php/ directory and tests selected php functions.
+Unit tests can be found in the php/ directory. They test selected php functions.
Very low coverage.
To execute the test suite run
Very low coverage.
To execute the test suite run
### API Tests (`test/bdd/api`)
These tests are meant to test the different API endpoints and their parameters.
### API Tests (`test/bdd/api`)
These tests are meant to test the different API endpoints and their parameters.
-They require a to import several datasets into a test database.
+They require to import several datasets into a test database.
See the [Development Setup chapter](Development-Environment.md#preparing-the-test-database)
for instructions on how to set up this database.
See the [Development Setup chapter](Development-Environment.md#preparing-the-test-database)
for instructions on how to set up this database.
These tests check the import and update of the Nominatim database. They do not
test the correctness of osm2pgsql. Each test will write some data into the `place`
These tests check the import and update of the Nominatim database. They do not
test the correctness of osm2pgsql. Each test will write some data into the `place`
-table (and optionally `the planet_osm_*` tables if required) and then run
+table (and optionally the `planet_osm_*` tables if required) and then run
Nominatim's processing functions on that.
These tests need to create their own test databases. By default they will be
Nominatim's processing functions on that.
These tests need to create their own test databases. By default they will be
### Import Tests (`test/bdd/osm2pgsql`)
These tests check that data is imported correctly into the place table. They
### Import Tests (`test/bdd/osm2pgsql`)
These tests check that data is imported correctly into the place table. They
-use the same template database as the Indexing tests, so the same remarks apply.
+use the same template database as the DB Creation tests, so the same remarks apply.
The __data import__ stage reads the raw OSM data and extracts all information
that is useful for geocoding. This part is done by osm2pgsql, the same tool
that can also be used to import a rendering database. It uses the special
The __data import__ stage reads the raw OSM data and extracts all information
that is useful for geocoding. This part is done by osm2pgsql, the same tool
that can also be used to import a rendering database. It uses the special
-gazetteer output plugin in `osm2pgsql/output-gazetter.[ch]pp`. The result of
+gazetteer output plugin in `osm2pgsql/src/output-gazetter.[ch]pp`. The result of
the import can be found in the database table `place`.
The __address computation__ or __indexing__ stage takes the data from `place`
and adds additional information needed for geocoding. It ranks the places by
importance, links objects that belong together and computes addresses and
the search index. Most of this work is done in PL/pgSQL via database triggers
the import can be found in the database table `place`.
The __address computation__ or __indexing__ stage takes the data from `place`
and adds additional information needed for geocoding. It ranks the places by
importance, links objects that belong together and computes addresses and
the search index. Most of this work is done in PL/pgSQL via database triggers
-and can be found in the file `sql/functions.sql`.
+and can be found in the files in the `sql/functions/` directory.
The __search frontend__ implements the actual API. It takes search
and reverse geocoding queries from the user, looks up the data and
The __search frontend__ implements the actual API. It takes search
and reverse geocoding queries from the user, looks up the data and