Search code examples
djangosolrdjango-haystack

Django-haystack & solr : Increase the number of results


I have this function :

def search_books(request):
    search_text = request.POST.get('search_text')
    if search_text:
        books = SearchQuerySet().filter(content=search_text).filter(quantite__gte=0)

    else:
        books = []
    return render_to_response("search/search.html", {'books': books})

By default it returns only 20 results, is there a way to increase that number?

Thanks.


Solution

  • This is specified by the HAYSTACK_SEARCH_RESULTS_PER_PAGE setting [readthedocs.io]. You can specify a different number in the settings.py file:

    # settings.py
    
    # …
    
    HAYSTACK_SEARCH_RESULTS_PER_PAGE = 50
    
    # …