a simple elasticsearch app for fast searching of data. The Project was initialized using spring initializer which autoconfigured all required dependencies via Maven.
Start ElasticSearch using docker
To set up the docker compose -
- Make sure docker is installed and running. Then run 'docker-compose up -d' in your terminal. This command will start an Elasticsearch container locally on port 9200.
- To verify, visit http://localhost:9200 in your browser or postman. You should see a JSON response from Elasticsearch if it's working correctly.
When you start the application, bulk indexing is automatically triggered.
This loads data from a predefined JSON file into the Elasticsearch database.
You can verify that the data has been successfully indexed by hitting the following GET endpoint using Postman or your browser:
http://localhost:9200/coursedocument/_search?pretty
This will return all indexed documents in a pretty-printed JSON format (with default pagination).
Use the /api/search endpoint to search for courses with various filters and combinations.
- Basic Search By keyword (Title/Description)
curl - GET http://localhost:8081/api/search?q=Science
Expected Behavior:
Returns all courses with "Science" in the title or description.
JSON includes total count of matches (which should be 5 in this case) and paginated result set. The JSON should contain the following elements -
"id": "4",
"title": "Science Fest",
"id": "29",
"title": "DIY Science Fair",
"id": "42",
"title": "Science Magic Club",
"id": "47",
"title": "Science Fair Prep Workshop",
"id": "18",
"title": "Science Club",
"total": 5
- Search By type (sorted)
curl - GET http://localhost:8081/api/search?type=ONE_TIME&sort=priceDesc
Expected Behavior:
Returns all courses with type "ONE_TIME" and properly sorted in descending order w.r.t. price.
JSON includes total count of matches (which should be 12 in this case) and paginated result set.Search By type. The JSON should contain the following elements -
"id": "12",
"title": "Robotics Camp",
"id": "23",
"title": "Space Explorers Camp",
"id": "16",
"title": "Astronomy Night",
"id": "29",
"title": "DIY Science Fair",
"id": "47",
"title": "Science Fair Prep Workshop",
"id": "17",
"title": "Maker Fair 2025",
"id": "26",
"title": "Art & Craft Bonanza",
"id": "35",
"title": "Astronomy Night",
"id": "39",
"title": "Environment Day Special",
"total": 12
- Search by category (greater than given age)
curl - GET http://localhost:8081/api/search?minAge=10&category=Music
Expected Behavior:
Returns all courses that are in "Music" category and filter that have minAge greater than "10".
JSON includes total count of matches (which should be 2 in this case) and paginated result set. The JSON should contain the following elements -
"id": "1",
"title": "Intro to Guitar",
"id": "46",
"title": "Music Production 101",
"total": 2
curl - GET http://localhost:8081/api/suggest?partial=Science
Expected Behavior:
Returns a JSON array of all the titles with Science as there prefix
JSON includes all the title names. For this curl it should be -
[
"Science Club",
"Science Fair Prep Workshop",
"Science Fest",
"Science Magic Club"
]
This is done in the same curl as the searching one.
To test this enhancement in your Postman hit the endpoint -
curl - GET http://localhost:8081/api/search?q=ciding
(The word 'coding' here is misspelled as 'ciding')
Expected Behavior:
Returns a JSON array of all the titles with Coding in their titles
JSON includes all the title names(there should be 2 elements in this case).The JSON should contain the following elements -
"id": "7",
"title": "Coding for Beginners",
"id": "36",
"title": "Coding Bootcamp for Beginners",
"total": 2
[PS - the lombok in my intellij is apparently not working. For which reason, I have made all the necessary constructors
and getters/setters in my entity. My guess is maven is not connected to the java version 17 even though it is clearly there in the path variable.
For some reason it is still connected version 11. But that is for me to look into!]
[Another PS - Hope you liked what i have made and faced little to no difficulties in any way]
Really enjoyed building this assignment with the very interesting but enough deadline! I learned a lot through this project!