Skip to content
LocusQ

Pelias geocoding for any country, in one stack

Geocoder is a fork of Pelias with Elasticsearch, libpostal, Placeholder, pip and interpolation in one Docker Compose stack. COUNTRY_CODE is the only switch, and only the API is published.

Search

0.2.0Free

01What it does

From an extract to a search API

fetch stages the OSM extract, Who's On First and GeoNames, prepare builds the Placeholder store, street polylines and interpolation data, import loads Elasticsearch and up starts the serving stack.

bash
./locusq-geocoder fetch LU                # stage the PBF, WOF and GeoNames into ./data
./locusq-geocoder prepare                 # Placeholder store, street polylines, interpolation DBs
./locusq-geocoder import                  # import into pelias_<runid>, then swap the alias
./locusq-geocoder up                      # serving stack; only the API is published

Imports swap in atomically

Each import writes a new pelias_<runid> index and then moves the pelias alias, so a running stack serves the new data at once. Backups are Elasticsearch snapshots. Inputs can also come from DataGen output.

Keys required, internals private

Every geocoding route needs a bearer key, compared as a SHA-256 digest. Elasticsearch, Placeholder, pip, libpostal and interpolation sit on an internal network with no host ports and no egress.

bash
curl -sS -H @<(printf 'Authorization: Bearer %s\n' "$(head -n1 .secrets/api_keys)") \
  'http://127.0.0.1:4000/v1/search?text=Esch-sur-Alzette&size=1'

02Install

Run Geocoder yourself

  1. Get access

    The repositories and packages are private while LocusQ is in private release. Ask for access and say which tools you need.

  2. Set the cache directory and country

    Any country with a config/countries/<CC>.env works the same way. You need Docker with compose and buildx, plus bash, jq, flock, openssl, sha256sum and md5sum.

    bash
    export GEOCODER_CACHE_DIR=/srv/cache/locusq-geocoder   # outside the repo
    export COUNTRY_CODE=LU
  3. Build, load and start

    bash
    bash scripts/docker-test.sh images        # libpostal data into the cache, then all 14 images
    ./locusq-geocoder secrets init            # ES passwords + one API key in ./.secrets (0600)
    ./locusq-geocoder fetch LU                # stage the PBF, WOF and GeoNames into ./data
    ./locusq-geocoder prepare                 # Placeholder store, street polylines, interpolation DBs
    ./locusq-geocoder import                  # import into pelias_<runid>, then swap the alias
    ./locusq-geocoder up                      # serving stack; only the API is published
    ./locusq-geocoder status

Search your own country

The guide covers the pipeline, the country switch and authentication.