An open API service indexing awesome lists of open source software.

https://github.com/hrishabh3829/course-search-spring

Course Search Backend (Spring Boot + Elasticsearch)
https://github.com/hrishabh3829/course-search-spring

spring-boot springweb

Last synced: about 1 month ago
JSON representation

Course Search Backend (Spring Boot + Elasticsearch)

Awesome Lists containing this project

README

          


🎯 Course Search Backend (Spring Boot + Elasticsearch)


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.


πŸš€ Getting Started


1. Prerequisites



  • βœ… 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


πŸ“Œ Features



  • πŸ” 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 Stack




TechVersion


Java17
Spring Boot3.2+
Elasticsearch7.17
Spring Data ESβœ…
Jacksonβœ…
Testcontainers1.19.0
JUnit 55.12.2



πŸ—‚οΈ Project Structure


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


πŸ”Ž API Endpoints




EndpointMethodDescription



/api/search?q=keyword
GET
Full-text search across title, description, category


/api/search/suggest?q=term
GET
Autocomplete suggestions using Elasticsearch completion field




πŸ§ͺ Running Tests


./mvnw test

This project uses Testcontainers to spin up a real Elasticsearch instance. Useful to ensure your logic works on actual Elasticsearch behavior.



πŸ™Œ How to Use This Project



  1. Clone the repo

  2. Start Elasticsearch using docker-compose up -d

  3. Run the Spring Boot backend using ./mvnw spring-boot:run

  4. Open Postman or your browser and hit:


    • http://localhost:9090/api/search?q=math

    • http://localhost:9090/api/search/suggest?q=art




πŸ‘ Contributing


This project is beginner-friendly. You are welcome to fork the repo and open PRs for improvements or suggestions.



πŸ™ Acknowledgement


Built as a learning project to explore Spring Boot and Elasticsearch integration. Thanks to the developer community for docs, samples, and support.



πŸ‘€ Author


Maintained by Hrishabh.

Built with passion, patience, and a focus on clean backend design.