I have 2 servers with Haystack:
- Server 1 . It has elasticsearch installed.
- Server2 . This object does not have elasticsearch, requests are made in Server1
My problem is pagination when I make requests from Server2 to Server1 :
- Server2 makes a request to Server1
- Server1 send all results back to Server2
- Server2 does pagination
But this is not optimal, if the query returns 10,000 objects, the query will be slow.
I know that you can send elasticsearch some values in the request ( size , from and to ), but I do not know if it is possible using Haystack , I checked the documentation and looked for it and did not find anything.
- How can I set up an inquiry to Haystack to obtain the results 10 to 10?
Edit
- Is it possible that if I do
SearchQuerySet()[10000:10010] , it will only query 10 items? - Or will he query all the elements and then filter them?
Edit2
I found this in Haystack Docs:
The function seems to do what I'm trying to do:
Limits the query by changing either the start, end, or both offsets.
And then I tried to do:
from haystack.query import SearchQuerySet sqs = SearchQuerySet() sqs.query.set_limits(low=0, high=4) sqs.filter(content='anything')
The result is a complete list, for example, I never add the set_limit line
source share