Skip to content

Pelias geocoder & Elasticsearch

Bodo Minea edited this page Dec 3, 2021 · 7 revisions

Install Elasticsearch as per their instructions, as Pelias needs it to store its data.

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
sudo apt-get install apt-transport-https
echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list
sudo apt-get update && sudo apt-get install elasticsearch
service elasticsearch start
systemctl enable elasticsearch

Install all of the Pelias geocoder components as it is described in their docs.

for repository in schema whosonfirst geonames openaddresses openstreetmap polylines api placeholder interpolation pip-service; do
	git clone https://github.com/pelias/${repository}.git # clone from Github
	pushd $repository > /dev/null                         # switch into importer directory
	npm install                                           # install npm dependencies
	popd > /dev/null                                      # return to code directory
done

Config

"api": {
        "services":{
           "libpostal": {
                "url": "http://localhost:4400"
           }
        },
    "accessLog": "common",
// ... default config ...

Creating the base schema

sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-icu
sudo service elasticsearch restart
cd schema
./bin/create_index

Data for the Placeholder service

curl -s https://data.geocode.earth/placeholder/store.sqlite3.gz | gunzip > data/store.sqlite3;
mv data/ placeholder/

Data imports From openstreetmap .osm.pbf files Configure the main pelias.json with the file locations

 "openstreetmap": {
      "datapath": "/root",
      "leveldbpath": "/tmp",
      "import": [{
        "filename": "city1.osm.pbf"
      },{"filename": "city2.osm.pbf"}]
    }

Run the import

cd pelias/openstreetmap/
npm start

From GTFS files

git clone https://github.com/HSLdevcom/pelias-gtfs.git
cd pelias-gtfs/
npm install
node import.js -d /path/to/gtfs

Configure imported Pelias data sources in pelias.json

"targets": {
      "auto_discover": true,
      "canonical_sources": ["whosonfirst", "openstreetmap", "openaddresses", "geonames", "gtfs"]
// ... default values ...
"source_aliases": {
        "osm": [ "openstreetmap" ],
        "gtfs":[ "gtfs"  ],
        "oa":  [ "openaddresses" ],
        "gn":  [ "geonames" ],
        "wof": [ "whosonfirst" ]
      },
// ... default values ...

Run all of the services

docker run -d -p 4400:4400 pelias/libpostal-service
screen -S pelias-placeholder -dm bash -c "cd pelias/placeholder; npm start"
screen -S pelias-pip -dm bash -c "cd pelias/pip-service; npm start"
screen -S pelias-api -dm bash -c "cd pelias/api; npm start"

Clone this wiki locally