Forum: Ruby on Rails [AAF] Odd total_hits situation

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Icenine J. (Guest)
on 2007-07-16 03:29
I'm fairly new to RoR so go easy please :).  I'm having a situation
where I'm using acts_as_ferret and getting odd results.  I'm trying to
implement pagination described at
http://www.igvita.com/blog/2007/02/20/ferret-pagin... but
the count of the number of results appears incorrect.

I have a model called Bookmark which contains 31 records.  In the
console, if I enter:

count = Bookmark.find_by_contents("yahoo OR work OR google", :conditions
=> ['private = ?', 0], :group => "url").total_hits

I receive "5" as the response. With the conditions and grouping, the
correct number of results should be 3.

If I then enter:

res = Bookmark.find_by_contents("yahoo OR work OR google", {:offset =>
0, :limit => 10}, :conditions => ['private = ?', 0], :group => "url")

I receive "3" as the response (the correct number).  It looks like if I
specify the offset and limit, I get the correct number of results and if
I leave it out of the query, I receive the number of results I would
receive if the :conditions and :group were ignored.  On the second
query, if I change the limit to something larger than 10 (100000 for
example), I still receive the correct number of results.

Can anyone think of a reason for this (am I doing something
incorrectly)?
This topic is locked and can not be replied to.