Search code examples
djangosolrdjango-haystack

Set count of rows in haystack


I use django-haystack. And when i execute this code:

    sqs = SearchQuerySet().auto_query(q)
    q_spell = sqs.spelling_suggestion()
    results = SearchQuerySet().filter(SQ(content=q_spell) | SQ(content=q)).load_all()

In console i see like this:

> 365645 [qtp1539768275-13] INFO  org.apache.solr.core.SolrCore  –
> [collection1] webapp=/solr path=/select/
> params={spellcheck=true&fl=*+score&start=**990**&q=*:*&spellcheck.count=1&spellcheck.collate=true&wt=json&fq=django_ct:(...)&**rows=10**}
> hits=2034 status=0 QTime=0

How i can count of rows for example 1000?


Solution

  • The number of items Haystack retrieves per query is controlled through HAYSTACK_ITERATOR_LOAD_PER_QUERY, but as the documentation states:

    This is not used in the case of a slice on a SearchQuerySet, which already overrides the number of results pulled at once.

    So using [0:1000] after the query set should allow you to get all 1000 results at once.