The following query works like a charm:
@styles = Style.search { fulltext params[:q] }
The problem I am facing is pagination. Here is the same pagination request:
@styles = Style.search { fulltext params[:q]; paginate :page => params[:page], :per_page => params[:page_limit] }
I have 11 Style entries.
If I have :page => 1 and :per_page => 10 , when I search for the 11th entry, I get an empty array returned for @styles.results
If I set :page=>2 and do the same search, I get the 11th style entry.
[11] pry(#<StylesController>)> params[:page]=2 => 2 [12] pry(#<StylesController>)> x=Style.search {fulltext params[:q]; paginate :page => params[:page], :per_page => params[:page_limit] } => <Sunspot::Search:{:fq=>["type:Style"], :q=>"hel", :fl=>"* score", :qf=>"name_textp full_name_textp", :defType=>"dismax", :start=>10, :rows=>10}> [13] pry(#<StylesController>)> x.results => [#<Style id: 15...>]
I thought it was about breaking up the search results, not the actual records in general
What is going on here and how to fix it?
EDIT
Well, let me try to explain it in a different way. Let's say I have these six entries:
1 => 'a' 2 => 'b' 3 => 'c' 4 => 'd' 5 => 'e' 6 => 'f'
Say I'm trying to find 'f'
Letter.search { fulltext 'f'; paginate :page => 1, :per_page => 5 }
My result will be an empty array []
Now let's say i try
Letter.search { fulltext 'f'; paginate :page => 1, :per_page => 6 }
Now my result [6 => 'f']