开发者

Why does django-sphinx only output 20 results? How can I get the rest?

开发者 https://www.devze.com 2022-12-27 05:35 出处:网络
Doing a search using django-sphinx gives me results._sphinx that says there were 68 results, but when I iterate over them, I can only get at the first 20 of them.

Doing a search using django-sphinx gives me results._sphinx that says there were 68 results, but when I iterate over them, I can only get at the first 20 of them.

I'm SURE there's a way around this, and that this is by design, but it's officially stumping the heck out of me. Does anybody know how to get the comp开发者_运维百科lete queryset?


I figured this out finally.

Apparently, the querysets only return 20 hits until you access the queryset. Or something like that.

So, if you explicitly want the iterate over the whole thing, you have to do:

for result in results[0:results.count()]:
    print result

Or something to that effect, which will query the entire thing explicitly. Ugh. This should be clearly documented...but it not.


After hacking through source, I set the _limit variable explicitly.. Does the job, and issues an actual limit:

qs = MyEntity.search.query(query_string)
qs._limit = limit
for result in qs:
    print result


work for me:

in sphinx config file:

   max_matches     = 5000

in django code:

   desc_obj = Dictionary.search.query( search_desc )
   desc_obj._maxmatches = 5000

or in settings:

   SPHINX_MAX_MATCHES = 5000
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号