Skip to content

Hrishabh3829/Course-Search-Spring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎯 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.

About

Course Search Backend (Spring Boot + Elasticsearch)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages