enhancement, feature, backend, performance, GSSoC 2026
Summary
StackIt's current search implementation (GET /api/questions with a keyword param) almost certainly uses $regex against question titles. This performs a full collection scan on every search — O(n) complexity — with no relevance ranking and no support for partial word matching or tag-based boosting. For a Q&A platform aspiring to be a professional Stack Overflow alternative, relevance-ranked full-text search is a baseline expectation.
Problem
$regex performs a full collection scan (no index used), degrading linearly as question count grows.
- No relevance ranking — results are returned in insertion order, not by semantic match quality.
- No stemming, stop-word filtering, or phrase-match support.
- Search does not cover answer bodies or tags — only question titles.
- No search analytics or autocomplete suggestions.
Impact
- As the question count grows beyond a few thousand, search becomes unusably slow.
- Poor relevance ordering means users cannot find the answers they need, undermining the platform's core value.
Proposed Solution
1. Add MongoDB text indexes on the questions collection:
// server/models/Question.js — add index
QuestionSchema.index(
{ title: 'text', body: 'text', tags: 'text' },
{
weights: { title: 10, tags: 5, body: 1 },
name: 'question_full_text_index'
}
);
2. Update the search controller to use $text with score-based sorting:
// server/routes/questions.js
if (keyword) {
const results = await Question.find(
{ $text: { $search: keyword } },
{ score: { $meta: 'textScore' } }
)
.sort({ score: { $meta: 'textScore' } })
.populate('author', 'username reputation')
.lean();
return res.json(results);
}
3. Add a migration script that builds the text index on the existing collection without downtime using createIndex with background: true.
4. Add tag-based autocomplete endpoint (GET /api/search/suggestions?q=<prefix>) for the search bar.
I am participating in GSSoC 2026. Could you please assign this issue to me?
enhancement, feature, backend, performance, GSSoC 2026
Summary
StackIt's current search implementation (
GET /api/questionswith akeywordparam) almost certainly uses$regexagainst question titles. This performs a full collection scan on every search — O(n) complexity — with no relevance ranking and no support for partial word matching or tag-based boosting. For a Q&A platform aspiring to be a professional Stack Overflow alternative, relevance-ranked full-text search is a baseline expectation.Problem
$regexperforms a full collection scan (no index used), degrading linearly as question count grows.Impact
Proposed Solution
1. Add MongoDB text indexes on the
questionscollection:2. Update the search controller to use
$textwith score-based sorting:3. Add a migration script that builds the text index on the existing collection without downtime using
createIndexwithbackground: true.4. Add tag-based autocomplete endpoint (
GET /api/search/suggestions?q=<prefix>) for the search bar.I am participating in GSSoC 2026. Could you please assign this issue to me?