项目简介
本项目是基于Spring Boot框架和Elasticsearch搜索引擎构建的小说管理系统。用户可通过该系统对小说数据进行增删改查操作,同时借助Elasticsearch实现高效的搜索与数据管理。
项目的主要特性和功能
数据管理
- 添加小说:通过HTTP POST请求向Elasticsearch添加新小说数据。
- 删除小说:通过HTTP DELETE请求依据ID删除Elasticsearch中的小说数据。
- 更新小说:通过HTTP PUT请求根据ID更新Elasticsearch中的小说数据。
- 查询小说:通过HTTP GET请求根据ID或查询参数从Elasticsearch获取小说数据。
搜索功能
- 全文搜索:支持依据作者、标题、字数范围等条件进行全文搜索。
- 分页查询:支持分页查询,便于用户浏览大量数据。
配置管理
- Elasticsearch客户端配置:通过
ESConfig
类配置Elasticsearch客户端,确保与Elasticsearch服务器的连接。
安装使用步骤
环境准备
- 安装Java 11或更高版本。
- 安装Spring Boot开发环境。
- 安装Elasticsearch并启动服务。
下载项目源码
假设用户已下载本项目的源码文件。
配置Elasticsearch
在application.properties
文件中配置Elasticsearch的连接信息:
properties
spring.elasticsearch.rest.uris=http://localhost:9200
运行项目
在项目根目录下执行以下命令启动Spring Boot应用:
bash
./mvnw spring-boot:run
使用API
- 添加小说:
bash curl -X POST "http://localhost:8080/novels" -H "Content-Type: application/json" -d '{"title":"小说标题", "author":"作者", "word_count":100000, "publish_date":"2023-01-01"}'
- 查询小说:
bash curl "http://localhost:8080/novels/1"
- 更新小说:
bash curl -X PUT "http://localhost:8080/novels/1" -H "Content-Type: application/json" -d '{"title":"更新后的标题", "author":"更新后的作者", "word_count":120000, "publish_date":"2023-02-01"}'
- 删除小说:
bash curl -X DELETE "http://localhost:8080/novels/1"
- 搜索小说:
bash curl "http://localhost:8080/novels/search?author=作者&title=标题&minWordCount=50000&maxWordCount=200000"
下载地址
点击下载 【提取码: 4003】【解压密码: www.makuang.net】