Bhupesh-V / tutorialdb

A search 🔎 engine for programming/dev tutorials,
MIT License
121 stars 60 forks source link

relevance of search results #55

Open Bhupesh-V opened 4 years ago

Bhupesh-V commented 4 years ago

Describe the bug Currently if we search java tutorials, the search results are javascript tutorials.

To Reproduce Steps to reproduce the behavior:

  1. Go to https://tutorialdb-app.herokuapp.com/search/?q=java
  2. Scroll down.
  3. 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

Bhupesh-V commented 4 years ago

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

bookRa commented 4 years ago

Hey @Bhupesh-V if nobody's worked on this already, I'd be happy to!

Bhupesh-V commented 4 years ago

@bookRa you can work on this :+1:

bookRa commented 4 years ago

@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

1 2 3 4

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 😅

Animesh-Ghosh commented 4 years ago

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.