Skip to content

Instantly share code, notes, and snippets.

@zuo1188
Created October 21, 2017 11:32
Show Gist options
  • Save zuo1188/a3062092c7adb977996e19ef0fa907ce to your computer and use it in GitHub Desktop.
Save zuo1188/a3062092c7adb977996e19ef0fa907ce to your computer and use it in GitHub Desktop.
参考http://pelias.io/install.html
1. 新建Install.sh,在其中增加:
for repository in schema api whosonfirst geonames openaddresses openstreetmap polylines; do
git clone https://github.com/pelias/${repository}.git # clone from Github
pushd $repository > /dev/null # switch into importer directory
git checkout production # or remove this line to stay with master
npm install # install npm dependencies
popd > /dev/null # return to code directory
done
执行sh install.sh
2. 在~/pelias.json中增加如下内容:
{
"esclient": {
"apiVersion": "2.3",
"keepAlive": true,
"requestTimeout": "120000",
"hosts": [
{
"env": "development",
"protocol": "http",
"host": "t0.map.design",
"port": 9200
}
],
"log": [
{
"type": "stdio",
"level": [
"error",
"warning"
]
}
]
},
"elasticsearch": {
"settings": {
"index": {
"number_of_replicas": "0",
"number_of_shards": "5",
"refresh_interval": "1m"
}
}
},
"interpolation": {
"client": {
"adapter": "null"
}
},
"dbclient": {
"statFrequency": 10000
},
"api": {
"accessLog": "common",
"host": "http://t0.map.design/",
"indexName": "pelias",
"version": "1.0",
"textAnalyzer": "addressit"
},
"schema": {
"indexName": "pelias"
},
"logger": {
"level": "debug",
"timestamp": true,
"colorize": true
},
"acceptance-tests": {
"endpoints": {
"local": "http://t0.map.design:3100/v1/",
"dev-cached": "http://pelias.dev.mapzen.com.global.prod.fastly.net/v1/",
"dev": "http://pelias.dev.mapzen.com/v1/",
"prod": "http://search.mapzen.com/v1/",
"prod-uncached": "http://pelias.mapzen.com/v1/",
"prodbuild": "http://pelias.prodbuild.mapzen.com/v1/"
}
},
"imports": {
"adminLookup": {
"enabled": false
},
"openstreetmap": {
"datapath": "/mnt1/pelias/openstreetmap",
"leveldbpath": "/tmp",
"import": [
{
"filename": "beijing.osm.pbf"
}
]
}
}
}
3. 安装elasticsearch
推荐2.3版,下载后解压即可
安装elasticsearch-head插件,方便查看数据,安装方法 elasticsearch/bin/plugin install mobz/elasticsearch-head
修改config/elasticsearch.yml ,增加network.host: 0.0.0.0,否则访问时会报elastic getsockopt: connection refused
测试地址:http://t0.map.design:9200/_plugin/head/
4. 创建elasticsearch schema
cd schema
node scripts/create_index.js
5. 导入osm数据
根据pelias.json中定义的osm数据的位置存放数据
cd openstreetmap
npm start
6 启动api
cd api
npm start
测试地址:http://t0.map.design:3100/v1/search?text=北京市地震局
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment