Import Geoname data to Elastic and enjoy millions of searchable locations in your app.
Geonames is the most comprehensive open source geo location data source with more than 11 million location points. Each location comes with a wealth of information and can be searched in both English and local languages.
Elasticsearch is the leading open source search engine.
Local Geonames Manager connects these powers together and geo-enables your app without api restrictions. Local Geonames Manager allows you to import easily geo data into elasticsearch. This process can be done by using a console aplication called local-geonames-manager-cli.js (included in this repository)
- Blazing fast buffered import with batch indexing in elastic
- Filter unwanted data based on their type (city / country etc)
- Elastic schema included
To make it work you must install the following open-source software:
- Node.js. You can download from https://nodejs.org/es/download/
- Elasticsearch. You can download from https://www.elastic.co/downloads/elasticsearch
Don´t be afraid! Default installation works!
$ npm install
$ curl -XPUT http://127.0.0.1:9200/geonames -d @data/schema.json
Use the included command line tool to download all data files
$ node local-geonames-manager-cli -downloadall
then add all files to elastic
$ node local-geonames-manager-cli -addall
You can also download and add individual countries, e.g. for Spain
$ node local-geonames-manager-cli -download ES
and add it
$ node local-geonames-manager-cli -add ES
After adding data, you can try searching as you do with elasticsearch API:
http://localhost:9200/geonames/geoname/_search?q=Madrid
If you need to reset all geonames data you can set the following request:
$ curl -XDELETE localhost:9200/geonames
No configuration is necessary if elastic runs on localhost port 9200 and you're fine with using geonames/geoname as index/type in elastic.
Otherwise you can edit data/cli-config.json or use environment variables:
$ export ELASTIC_URL="localhost:9200"
$ export ELASTIC_PATH="geonames/geoname"
$ export DATAPATH="/tmp/"
$ node local-geonames-manager-cli -download ES
- ELASTIC_URL: Address to connect to your elastic instance
- ELASTIC_PATH: Where to store data in elastic INDEX/TYPE, e.g. geonames/geoname
- DATAPATH: Path were to download and extract data files, defaults to temp directory
Copyright (c) 2018 Miguel A. Rozalén