3

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 complete queryset?

mlissner
  • 17,359
  • 18
  • 106
  • 169
  • 1
    I just discovered this, which I could just change, but I'm concerned this is here for my own protection: http://github.com/dcramer/django-sphinx/blob/master/djangosphinx/models.py#L206 – mlissner Apr 19 '10 at 23:04
  • I should add that changing that value didn't do much of anything for me. – mlissner Apr 22 '10 at 06:15

3 Answers3

2

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.

mlissner
  • 17,359
  • 18
  • 106
  • 169
0

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
iqmaker
  • 2,162
  • 25
  • 24
0

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
royal
  • 530
  • 1
  • 6
  • 12