mardi 13 octobre 2015

Thinking Sphinx - Sort by decimal fields

I'm running thinking-sphinx 3.1.0 and rails 3.2.13 with MySQL 14.14.

I'm trying to sort the results by a price field. The index looks like:

ThinkingSphinx::Index.define :book, :with => :active_record do
 indexes authors.title, :as => :title
 indexes price, :sortable => true, :as => :price, :type => :float
end

It sorts like this:

0.00
10.95
12.95
5.00
6.5
9.95

Looks like it keeps treating the price field as a string rather than a float or a decimal. Any help will be appreciated.

Aucun commentaire:

Enregistrer un commentaire