- git
- maven 3
- jdk 8+
- docker
- linux (docker on mac may be incompatible when pull images)
- mkdir autocomplete;cd autocomplete
- git clone -b master https://github.com/zhouquan2k/AutoComplete.git
- cd AutoComplete; mvn verify # deploy mysql container, run integration test, see testcase: ex.autocomplete.test.AutoCompleteApiIT
- chmod +x start_mysql; ./start_mysql # start mysql container
- mvn -D spring.profiles.active=prod exec:java # run rest api server, import about 190K city data to database when first time run
- TODO for production usage,should package to a docker image for easy deployment
- api: GET http://host:8088/suggestions?q= &latitude= &longitude=
- swagger doc: http://host:8088/swagger-ui.html
- remote url: http://tencent.atuspace.site:8088/swagger-ui.html
- distance = 6378.138 * 2 * ASIN( SQRT( POW( SIN( ( lat1 * PI() / 180 - lat2 * PI() / 180 ) / 2 ), 2 ) + COS(lat1 * PI() / 180) * COS(lat2 * PI() / 180) * POW( SIN( ( lng1 * PI() / 180 - lng2 * PI() / 180 ) / 2 ), 2 ) ) )
- score = distance/max distance * 0.8 + matched_length/city_name_length * 0.2
- (0.8,0.2 is the weight for distance and text match)
- ex.autocomplete: Rest API
- ex.autocomplete.impl.sql: using Sql to implement auto complete function
- compoment.mybatisex: extend Mybatis-Plus to support batch insert
- using integration test maven plugin: maven-failsafe-plugin
- using docker-maven-plugin to run mysql container for integration test
- Java 8
- SpringBoot 2.3 (WebServer and Rest API)
- MybatisPlus (ORM)
- Druid (DB Connection Pool Management)
- Mysql
- Swagger (http api doc)
- mybatis-enhance-actable (auto create table)
- maven plugins: maven-failsafe-plugin,docker-maven-plugin (Integration Test)
... see details in pom.xml