-
-
Notifications
You must be signed in to change notification settings - Fork 25
Improve search backend #647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughThis PR introduces a new feature flag Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Comment |
Greptile OverviewGreptile SummaryChanges introduce a new feature flag to control whether Cause search uses trigram word similarity (vs regular trigram similarity), aligning Cause search with existing NGO search tuning. In the mixed NGO+Cause search, the queryset union order was swapped so that results from the direct Cause search appear before causes inferred from matching NGOs. These changes live in the shared search mixins used by list views, and the new flag is loaded into Django settings via the existing Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| backend/donations/views/common/search.py | Switched Cause search similarity flag and changed union order in mixed search; needs verification that queryset union ordering change is intended and deterministic. |
| backend/redirectioneaza/settings/feature_flags.py | Added ENABLE_CAUSE_SEARCH_WORD_SIMILARITY flag; appears correctly imported via settings/init.py. |
Sequence Diagram
sequenceDiagram
participant U as User
participant V as Search View (CommonSearchMixin)
participant CS as CauseSearchMixin
participant NS as NgoSearchMixin
participant DB as Postgres (FTS + trigram)
U->>V: GET /... ?q=query
V->>V: _search_query() + min length checks
V->>CS: get_search_results(queryset, query, language)
CS->>CS: build SearchVector/SearchQuery
alt ENABLE_CAUSE_SEARCH_WORD_SIMILARITY
CS->>CS: TrigramWordSimilarity(query, "name")
else
CS->>CS: TrigramSimilarity("name", query)
end
CS->>DB: annotate(rank, similarity) + filter + distinct
DB-->>CS: causes queryset
CS-->>V: results
note over V,NS: Mixed search path
V->>NS: NgoSearchMixin.get_search_results(Ngo.active,...)
NS->>DB: search NGOs
DB-->>NS: ngos queryset
V->>DB: Cause.public_active.filter(ngo__in=ngos)
DB-->>V: ngos_causes queryset
V->>CS: CauseSearchMixin.get_search_results(queryset,...)
CS-->>V: searched_causes queryset
V-->>U: searched_causes | ngos_causes
Summary by CodeRabbit
Bug Fixes
Improvements