Sunspot solr, order_by integer value completely broken


I have problem using sunspot gem with solr

I'm using latest gem from git (2.1.1 also tried with 2.1.0), I've tried solr versions - 3.2, 3.5, 4.2, 4.9

The problem is that order by integer value completely not working.

My code is:

   @ads = Ad.solr_search do
     paginate :page => params[:page], :per_page => 10000 #just for debug, not working with 25 as well
     order_by :priority, :desc

In model sunspot initialized by following code:

searchable do
  text :search_name
  text :search_description
  integer :id
  integer :state_id
  integer :city_id
  integer :district_id
  boolean :moderated
  integer :category_id
  integer :priority
  integer :price_index
  latlon(:location) {, lon) }
  integer :ad_type_id
  boolean :active
  time :created_at

The result is complete mess -

I expect ads with highest priority will be shown first, but instead they are shown shuffled on the last(!) page.

What's interesting - when I apply more filters - like on price, city_id, state_id and something else - it's either start working correctly or at least glitching not that hard (like priority records shown on the first page but still some of them are shuffled). But the least filters I apply the more sorting is glitching, up to the point of being complete broken.

I've tried to Google similar issues but didn't found anything, also have tried everything that could affect the problem - different solr versions, different gem versions, tried to change code a little (however not much to change, to reproduce issue 3 lines of code is enough) - nothing changed the behavior. I've done reindex probably about 30 times - each time I'v tried different versions

Can anyone advice how to solve it or at least what else could be tried

Thanks in advance!

I have same problem. Order by integer type is not working.

So I use little bit tricky way. It's not good solution. but it will be temporary alternative before bug fixed.

Order by time type is working well. so integer converts to time.

My code is:

searchable do
  integer :priority
  time(:priority_to_time){, 1, 1, 0, 0, 0) + self.priority}

In search code do
  order_by(:priority_to_time, :desc)

Yeah it's very weird code. but it works.

If someone have more good idea, please advice for us.