feat(search): implement full-text course search with Meilisearch - #112
Open
islarmeeyah-cyber wants to merge 1 commit into
Open
feat(search): implement full-text course search with Meilisearch#112islarmeeyah-cyber wants to merge 1 commit into
islarmeeyah-cyber wants to merge 1 commit into
Conversation
Add full-text search integration for courses using Meilisearch. - New SearchModule with Meilisearch client, index management, and query sanitization - Search endpoint with GET/POST, highlights, filters, and pagination - Auto-sync course index on approval and update - Index freshness tracking per course via lastIndexedAt timestamp - Profanity filtering via bad-words library - Relevance ranking configuration with sortable/filterable attributes Closes Hamplard-Hub#30
|
@islarmeeyah-cyber Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
@islarmeeyah-cyber Kindly resolve conflict |
1 similar comment
Contributor
|
@islarmeeyah-cyber Kindly resolve conflict |
Contributor
|
Hi @islarmeeyah-cyber , This PR could not be merged because it has merge conflicts with the target branch. Please resolve the merge conflicts, push the updated changes, and the PR can be reviewed and merged. Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR implements a dedicated full-text search engine for course content using Meilisearch, replacing the existing basic
WHERE title ILIKEapproach with proper indexing, relevance ranking, query sanitization, and highlighted results.Related Issue
Closes #30
Changes
📦 New Search Module
[ADD]
src/modules/search/search.module.ts— NestJS module exportingSearchService, importingConfigModulefor Meilisearch connection config.[ADD]
src/modules/search/search.service.tscoursesindex on startup (searchable/filterable/sortable/displayed attributes, ranking rules).indexCourse()/removeCourse()/bulkIndexCourses()— document sync operations withlastIndexedAtfreshness tracking.search()— full-text search with optional category/level/language filters, highlighted matches, pagination, and relevance sorting.bad-words, empty query rejection, filter value escaping.getIndexFreshness()— returns epoch ms of last index update per course.words → typo → proximity → attribute → sort → exactness.[ADD]
src/modules/search/search.controller.tsGET /search— public search with query params (query,category,level,language,page,limit).POST /search— same via request body with validation DTO.GET /search/freshness/:courseId— check when a course was last indexed.[ADD]
src/modules/search/dto/search-query.dto.ts— validated DTO for POST body.🔗 Integration with Courses Module
src/modules/courses/courses.module.ts— importsSearchModule.src/modules/courses/courses.service.ts— injectsSearchService; auto-indexes courses on:approve()— indexes when a course is approved (status → ACTIVE).update()— re-indexes when an active course is updated.indexCourseForSearch()helper buildsCourseSearchDocumentfrom Prisma data.⚙️ Configuration
MEILISEARCH_HOSTandMEILISEARCH_API_KEYenv vars in.env.example.📋 Dependencies
meilisearch(^0.40.0) — Meilisearch HTTP client.bad-wordsand@types/bad-words— profanity filter for query sanitization.Verification Results
indexCourse()/removeCourse()/bulkIndexCourses()— auto-sync on course approval and updatelastIndexedAtfield;GET /search/freshness/:courseIdendpoint returns itavgRating:descdefaultattributesToHighlightontitle/descriptionwithshowMatchesPosition: true