This is a lightweight backend application for searching and filtering courses using Elasticsearch. It supports full-text search, autocomplete, and optional fuzzy matching — built with Spring Boot, Java 17, and tested using Testcontainers.
- ✅ Java 17
- ✅ Maven 3+
- ✅ Docker (for Elasticsearch container)
2. Clone the Repository
git clone https://github.com/your-username/course-search.git
cd course-search
3. Start Elasticsearch with Docker Compose
docker-compose up -d
4. Run the Spring Boot Application
./mvnw spring-boot:run
5. Verify Initialization
You should see:
👍Courses indexed into Elasticsearch: 50
- 🔍 Full-text search (title, description, category)
- ⚡ Autocomplete suggestions (prefix-based)
- 🤖 Fuzzy matching for typo-tolerance
- 📝 50 sample courses indexed at startup
- 🧪 Integration tests using Testcontainers + JUnit 5
| Tech | Version |
|---|---|
| Java | 17 |
| Spring Boot | 3.2+ |
| Elasticsearch | 7.17 |
| Spring Data ES | ✅ |
| Jackson | ✅ |
| Testcontainers | 1.19.0 |
| JUnit 5 | 5.12.2 |
src/
├── main/
│ ├── java/com/example/coursesearch/
│ │ ├── config/ # Jackson & other app-level configs
│ │ ├── controller/ # API endpoints
│ │ ├── document/ # Elasticsearch @Document definitions
│ │ ├── repository/ # Spring Data Elasticsearch repositories
│ │ └── service/ # Business logic (search, indexing)
│ └── resources/
│ ├── application.yml
│ └── sample-courses.json # Initial 50-course dataset
└── test/ # Integration testing with Testcontainers| Endpoint | Method | Description |
|---|---|---|
/api/search?q=keyword |
GET | Full-text search across title, description, category |
/api/search/suggest?q=term |
GET | Autocomplete suggestions using Elasticsearch completion field |
./mvnw testThis project uses Testcontainers to spin up a real Elasticsearch instance. Useful to ensure your logic works on actual Elasticsearch behavior.
- Clone the repo
- Start Elasticsearch using
docker-compose up -d - Run the Spring Boot backend using
./mvnw spring-boot:run - Open Postman or your browser and hit:
http://localhost:9090/api/search?q=mathhttp://localhost:9090/api/search/suggest?q=art
This project is beginner-friendly. You are welcome to fork the repo and open PRs for improvements or suggestions.
Built as a learning project to explore Spring Boot and Elasticsearch integration. Thanks to the developer community for docs, samples, and support.