I'm working with Rails and thinking sphinx. I have a model Product indexed as following (only showing relevant information)
define_index do
indexes :name, :as => :name, :sortable => true
indexes color, :facet => true
...
indexes price, :as => :range, :facet => true
has created_at, price, root_category_id
...
end
What I need is to get the Product with max price of the current search. I've tried something like
Product.search('', :select => 'MAX(price)')
but it's returning me a mess.
>> Product.search_for_ids( :select => 'MAX(price)')
Sphinx Query (3.0ms)
Sphinx Found 732 results
Product Load (0.4ms) SELECT MAX(price) FROM `products` WHERE `products`.`id` IN (388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 401, 402, 403, 404, 405, 406, 407, 408)
=> [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil]
I really don't understand why it's doing that strange query, why it's adding that where and why it's returning an array.
Regards, Franco.