-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
To give you a better example, let's start with this snippet:
class Document ... @@riddle=Riddle::Client.new scope :search, ->(query){ where(:document_id.in => sphinx_get_ids(query)) } def self.sphinx_get_ids(query) @@riddle.query(query)[:matches].collect {|match| match[:attributes]["doc_id"]} end end
Don't mind class variable just for now.
What I would like to do is pass precise values of skip and limit that are present at the moment to Riddle selector before actually passing the critera to Moped.
So I can
# do this Document.search('graceful aubergine').page(5).per(10) # exactly like this, without any unnecessary fetching Document.where(:field.gt => 10).page(5).per(10)
Latter call is paginated perfectly, but former one will require some overhead, because Sphinx will return all IDs and only after that they will be paginated. Creating a query having "in" clause with thousands of IDs to select 10 of them seems inappropriate, to say the least.
Is it possible in current version of Mongoid/Origin, and if it's not, does it look like something to be implemented somewhere soon?