Example of implementing CRUD operations for Elasticsearch in Spring Boot applications
The application is designed as an internal microservice with no user interface.
Once the application is launched, it will need to communicate with Elasticsearch. The following endpoints will then be available:
Method | Path | Description |
---|---|---|
POST | /items |
Registration of a new document to be saved in Elasticsearch |
GET | /items/get/{id} |
Find a document by ID |
GET | /items/search/{term} |
Find all documents by content |
GET | /items/{pageNumber}/{pageSize} |
Getting all documents with pagination |
POST | /items/update |
Update document. If document with ID not exist, it will be saved in Elasticsearch |
DELETE | /items/{id} |
Delete the document by ID |
API documentation will be available once the application is started
Java
- version21
Maven
- for building the applicationSpring Boot
- version3.4.3
Spring Cloud
- version2023.0.3
Spring Boot Actuator
- it's for real-world applicationsSpring Boot Maven Plugin
- for create Docker-ImageDocker
- containerizationDocker-Compose
- infrastructureElasticsearch
- version8.17.2
as NoSQL database
spring-boot-with-mongodb-in-action/
├── src/main/
| ├── java/com/dudko/example/
| | ├── controller/ # domain level of requests and controllers
| | ├── domain/ # persistent domain level and repositories
| | ├── model/ # service level of the domain, used in business logic
| | ├── service/ # business logic
| ├── resources/ # configs
├── compose.yml # docker-compose file
├── pom.xml # artifact of Maven
├── postman_collection.json # collection of requests for Postman
docker-compose -f compose.yml up
Anatoly Dudko