# 智能地址解析 **Repository Path**: zhangxiaolong1989/smart_address_resolution ## Basic Information - **Project Name**: 智能地址解析 - **Description**: 基于Elasticsearch的搜索引擎方式智能地址解析。支持地址别名匹配,自定义地址分词。支持中英文地址智能解析。支持国家、省、市、区、镇 地址智能匹配,支持中文繁体字地址解析,后续版本将支持多语言地址解析。 - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 39 - **Forks**: 0 - **Created**: 2019-11-22 - **Last Updated**: 2025-11-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 智能地址解析 #### 介绍 基于Elasticsearch的搜索引擎方式智能地址解析。支持地址别名匹配,自定义地址分词。支持中英文地址智能解析。支持国家、省、市、区、镇 地址智能匹配。 代码资源文件包含中国地址字典库。首先需要调用初始化地址字典库接口初始化地址字段索引 #### 软件架构 SpringBoot + Elasticsearch + Maven + assembly #### 安装教程 1. `git clone https://gitee.com/zhangxiaolong1989/smart_address_resolution.git` 2. `mvn clean package` 3. **Elasticsearch 索引结构中 省、市、区(县)、镇(乡) 中 _alias 的是以#做分词,如果名字发生变化可以进行添加,兼容老的地名。** 4. **地址解析返回内容中 省、市、区(县)、镇(乡) 字段取不带 '_alias' 字段,这些字段是官方名称。** #### 使用说明 1. 修改smart-address-platform-api resource 下的application-dev.yaml 中 es 配置(未xpack的无需修改xpack配置) 2. 创建Elasticsearch 索引,索引模板文件:smart-address-platform-api resource 下 address_es_index_mapping.json 3. 启动服务 tar -zxvf smart-address-platform-api-1.0.0-bin.tar.gz sh smart-address-platform-api-1.0.0/bin/start.sh 4. 初始化地址库 curl http://{localhost:8080}/address/init 5. 地址解析 curl -XPOST http://{localhost:8080}/address/parse -H "Content-Type:application/json" -d '{"address":"陕西宝鸡扶风城关镇小留村"}' 6. html页面地址测试:直接在浏览器打开 smart-address-platform-api resource 下的address.html (需要修改html 代码中访问的后台服务地址) ### 效果展示 举例:“陕西省西安市鄠邑区” 原名 陕西省西安市户县 ,为了兼容两个名字 我们在district_alias 字段中列出兼容的地名,以#分割: 鄠邑区#鄠邑#鄠邑区#户县#鄠县 1. ES索引数据结构 ``` { "_index": "cloud_address_resolve_uat", "_type": "cloud_address_resolve_type", "_id": "07P0kW4B6oMTglIf236B", "_score": 7.651121, "_source": { "country": "中国", "country_alias": "中华人民共和国#中国", "city_alias": "西安市#西安", "town": "甘河镇", "create_time": "2019-11-18 15:00:00", "city": "西安市", "province_alias": "陕西省#陕西", "city_code": "610100", "language": "zh-cn", "province_code": "610000", "country_code": 0, "town_alias": "甘河镇", "town_code": "610118109", "update_time": "2019-11-18 15:00:00", "is_deleted": 0, "province": "陕西省", "district_code": "610118", "district": "鄠邑区", "district_alias": "鄠邑区#鄠邑#鄠邑区#户县#鄠县" } } ``` 2.匹配效果展示(解析地址:陕西西安户县甘河镇) ``` curl -XPOST http://192.168.207.28:8080/address/parse -H "Content-Type:application/json" -d '{"address":"陕西西安户县甘河镇"}' { "status": 200, "message": "OK", "data": { "id": 0, "country": "中国", "province": "陕西省", "provinceCode": "610000", "city": "西安市", "cityCode": "610100", "district": "鄠邑区", "districtCode": "610118", "town": null, "townCode": null, "originAdd": "陕西西安户县甘河镇", "name": null, "detail": "甘河镇" }, "timestamp": "2019-11-22T08:24:48.899+0000" } ``` 3.匹配效果展示(解析地址:陕西省西安市鄠邑区甘河镇) ``` curl -XPOST http://192.168.207.28:8080/address/parse -H "Content-Type:application/json" -d '{"address":"陕西省西安市鄠邑区甘河镇"}' { "status": 200, "message": "OK", "data": { "id": 0, "country": "中国", "province": "陕西省", "provinceCode": "610000", "city": "西安市", "cityCode": "610100", "district": "鄠邑区", "districtCode": "610118", "town": null, "townCode": null, "originAdd": "陕西西安户县甘河镇", "name": null, "detail": "甘河镇" }, "timestamp": "2019-11-22T08:24:48.899+0000" } ``` 4.自己写了一个html界面方便测试人员测试地址 ![输入图片说明](https://images.gitee.com/uploads/images/2019/1122/163920_9cdaa92c_5486517.jpeg "address.jpg")