This repository contains the source code of Webflux SpringBoot application for the demonstration of integration with Elasticsearch.
There are 3 API endpoints for product queries:
- List products by category -
GET /products/by-category?category=<category>
- Search products by keyword -
GET /products/by-keyword?keyword=<keyword>
- Search relevant products -
GET /products/{productId}/relevant-products
The system structure is based on the typical Controller-Service-Repository
design pattern.
Repository makes use of ReactiveElasticsearchTemplate
for the access to Elasticsearch
Docker environment is required as disposable Elasticsearch docker container is created during the automated test execution.
This application needs to connect to Elasticsearch. Run this command to start up Elasticsearch in docker container:
cd docker-compose
docker compose up
Then, import sample product data into Elasticsearch
run-logstash.sh
Use maven command to build the source and run automated tests
mvn clean test
Finally, run this command to start the SpringBoot application:
mvn spring-boot:run