SpringBoot + MySQL + Elasticsearch 打造房产租赁信息搜索平台
《基于 SpringBoot MySQL Elasticsearch 的房产租赁信息搜索平台》✅ 全文检索✅ 中文分词✅ 高亮 / 分页 / 筛选✅ 数据同步✅ 技术深度足够答辩老师基本不会为难你一、项目背景论文 / 实战通用随着房产租赁市场的发展用户对房源搜索的体验要求越来越高传统 SQLLIKE查询性能差、匹配不智能无法支持模糊、同义词、纠错筛选条件多组合复杂数据量大时响应慢本系统基于SpringBoot MySQL Elasticsearch实现✅ 房源信息全文检索✅ 中文分词 高亮显示✅ 多条件组合筛选✅ MySQL ↔ ES 数据同步✅ 近实时搜索二、技术架构前端Vue / Thymeleaf ↓ SpringBoot ├── 搜索接口ES ├── 房源管理MySQL ├── 数据同步模块 ↓ MySQL源数据 Elasticsearch全文索引技术作用SpringBoot快速开发MyBatisORMMySQL持久化存储Elasticsearch 7.x全文检索IK 分词器中文分词RestHighLevelClientES Java 客户端三、系统功能模块房产租赁搜索平台 ├── 房源管理模块 │ ├── 发布房源 │ └── 编辑 / 下架 ├── 全文检索模块⭐核心 │ ├── 关键词搜索 │ ├── 高亮显示 │ └── 分页排序 ├── 组合筛选模块 │ ├── 价格区间 │ ├── 区域 / 户型 │ └── 标签筛选 ├── 数据同步模块 │ └── MySQL → ES └── 用户模块四、数据库设计MySQL1️⃣ 房源表houseCREATE TABLE house ( id BIGINT PRIMARY KEY AUTO_INCREMENT, title VARCHAR(100), description TEXT, price DECIMAL(10,2), area DECIMAL(8,2), room_count INT, hall_count INT, floor INT, total_floor INT, direction VARCHAR(20), district VARCHAR(50), address VARCHAR(200), tags VARCHAR(200), -- 近地铁,精装修 status INT DEFAULT 1, create_time DATETIME, update_time DATETIME );五、ES 索引设计⭐核心1️⃣ 创建索引 IK 分词PUT /house_index { settings: { number_of_shards: 1, analysis: { analyzer: { ik_max_word: { type: ik_max_word } } } }, mappings: { properties: { id: { type: long }, title: { type: text, analyzer: ik_max_word }, description:{ type: text, analyzer: ik_max_word }, price: { type: double }, area: { type: double }, roomCount: { type: integer }, district: { type: keyword }, tags: { type: keyword }, createTime: { type: date } } } }2️⃣ 实体类HouseESData Document(indexName house_index) public class HouseES { private Long id; private String title; private String description; private Double price; private Double area; private Integer roomCount; private String district; private ListString tags; private Date createTime; }六、数据同步MySQL → ES方式一同步写入简单Transactional public void save(House house) { // 1. 写 MySQL houseMapper.insert(house); // 2. 写 ES HouseES es convert(house); restHighLevelClient.index( new IndexRequest(house_index) .id(house.getId().toString()) .source(JSON.toJSONString(es), XContentType.JSON) ); }方式二定时同步推荐Scheduled(cron 0 */5 * * * ?) public void sync() { ListHouse list houseMapper.selectUpdatedAfter(lastSyncTime); for (House h : list) { updateES(h); } }七、全文检索核心实现⭐重点1️⃣ 构建搜索条件SearchRequest request new SearchRequest(house_index); BoolQueryBuilder boolQuery QueryBuilders.boolQuery(); // 1. 全文检索 if (StringUtils.isNotBlank(keyword)) { boolQuery.must(QueryBuilders.multiMatchQuery(keyword, title, description)); } // 2. 价格区间 if (minPrice ! null) { boolQuery.filter(QueryBuilders.rangeQuery(price).gte(minPrice)); } if (maxPrice ! null) { boolQuery.filter(QueryBuilders.rangeQuery(price).lte(maxPrice)); } // 3. 区域 if (StringUtils.isNotBlank(district)) { boolQuery.filter(QueryBuilders.termQuery(district, district)); } // 4. 户型 if (roomCount ! null) { boolQuery.filter(QueryBuilders.termQuery(roomCount, roomCount)); }2️⃣ 高亮 分页// 高亮 HighlightBuilder highlight new HighlightBuilder() .field(title) .preTags(em) .postTags(/em); // 分页 SearchSourceBuilder source new SearchSourceBuilder() .query(boolQuery) .highlighter(highlight) .from((pageNum - 1) * pageSize) .size(pageSize) .sort(createTime, SortOrder.DESC); request.source(source);3️⃣ 解析结果SearchResponse response restHighLevelClient.search(request, RequestOptions.DEFAULT); for (SearchHit hit : response.getHits()) { HouseES house JSON.parseObject(hit.getSourceAsString(), HouseES.class); // 取高亮 MapString, HighlightField hl hit.getHighlightFields(); if (hl.containsKey(title)) { house.setTitle(hl.get(title).fragments()[0].string()); } }八、搜索接口ControllerGetMapping(/search) public RPageResultHouseES search( RequestParam(required false) String keyword, RequestParam(required false) Double minPrice, RequestParam(required false) Double maxPrice, RequestParam(defaultValue 1) Integer pageNum ) { return R.ok(searchService.search(keyword, minPrice, maxPrice, pageNum)); }九、搜索页面前端示例form action/search input typetext namekeyword placeholder搜索小区/商圈/地铁 价格 input nameminPrice placeholder最低价 ~ input namemaxPrice placeholder最高价 button搜索/button /form div th:eachh : ${list} h3 th:utext${h.title}/h3 p th:text${h.description}/p span th:text${h.price} 元/月/span /div十、系统特色⭐答辩亮点✅ Elasticsearch 全文检索✅ IK 中文分词 高亮✅ 多条件组合筛选✅ MySQL ↔ ES 数据同步✅ 近实时搜索✅ 可扩展为租房平台核心搜索十一、可扩展方向工作量拉满✅ 地理位置搜索geo_point✅ 自动补全 / 搜索建议suggest✅ 竞价排名 / 房源置顶✅ 搜索热词统计✅ 分布式 ES 集群✅ 接入大模型做智能问答十二、毕设论文结构建议章节内容第1章绪论第2章相关技术第3章需求分析第4章系统设计ES 索引设计第5章系统实现全文检索核心第6章系统测试第7章总结与展望