feat: implement weighted search for title and description #87
Conversation
|
Hi @AyushDharDubey, I've opened a PR to address this issue. I implemented PostgreSQL's full-text search with a weighted ranking system ( |
AyushDharDubey
left a comment
There was a problem hiding this comment.
Looks mostly good, could you please include tests to support the implementation.
|
@AyushDharDubey I've pushed the requested changes:
Everything is tested and passing locally. |
lonvia
left a comment
There was a problem hiding this comment.
I haven't tried it but looks good to me in general. We might want to adjust the similarity threshold a bit upwards later. 0.1 is quite small. But we can try with real data first to see how it comes out.
|
@lonvia I originally kept the variable when refactoring the filtering precedence, but you're absolutely right that it's no longer necessary. I've updated |
|
Hi @AyushDharDubey, thanks for the approval! Just a quick bump to see if you or @lonvia could approve the GitHub actions workflow to run so this can merge. No rush! |
|
Hello, we were actually expecting for you to address Sarah's review, which may have been overlooked. |
aec8c9a to
df8a8f8
Compare
008b138 to
9cb70c7
Compare
|
@AyushDharDubey I have done the changes. Is it good to go? |
|
Hello Kunal, this partially addresses the previous review. However, we still need to restore the The updated |
|
@AyushDharDubey Sorry for the partial address last time! I've now restored the |
Closes #83.
Description
This PR updates the search functionality to query both the title and
descriptionfields with a weighted ranking system, rather than just the genericicontainslookup. This significantly improves model discoverability by factoring in metadata relevance.Changes made
SearchVector,SearchQuery, andSearchRank).A.descriptionmatches are assigned weightB.rank__gte=0.01) to exclude completely irrelevant results, and sorted the results by-rankto ensure the most contextually relevant models appear first.-rankin the views.py search view mistakenly applied to unrelated querysets (like category).Testing
django.contrib.postgres).