tutorialdb
tutorialdb copied to clipboard
relevance of search results
Describe the bug Currently if we search java tutorials, the search results are javascript tutorials.
To Reproduce Steps to reproduce the behavior:
- Go to https://tutorialdb-app.herokuapp.com/search/?q=java
- Scroll down.
- See error.
Expected behavior Relevant search results should appear, we have to give preference to Java tutorials instead of JavaScript.
Additional context Maybe we need to add priorities to tags.
Issue raised by Daiyrbek Artelov on DEV.to
It seems that I am ordering the results based on their id
instead of search text :confounded:
In the method search_query()
if category is not None:
tutorials = Tutorial.objects.filter(
(Q(title__icontains=query) | Q(tags__name__in=list_query))
& Q(category__icontains=category)
).order_by('id').filter(publish=True).distinct()
else:
tutorials = Tutorial.objects.filter(
(Q(title__icontains=query) | Q(tags__name__in=list_query))
).order_by('id').filter(publish=True).distinct()
removing .order_by('id')
would probably fix the problem
Hey @Bhupesh-V if nobody's worked on this already, I'd be happy to!
@bookRa you can work on this :+1:
@Bhupesh-V how do I spin up this app and use it locally with a database of tutorials? I've used python manage.py runserver
to get it on my localhost. But whenever I add a link through "contribute," some corresponding tags are registered, but the actual links to the tutorials are missing. I cannot search for them
I would appreciate any advice, or step-by-step to working with the local database. Sorry if it's obvious but I don't have too much exp with Django framework 😅
It's not a database issue as far as I know. We added a published
field in the database model a while back.
@bookRa, you need to publish the added tutorial through the admin site. That will make the tutorial visible on the site.