0
我正在使用Rails和思维狮身人面像。我有一个模型产品索引如下(只显示相关信息)用思维狮身人面像获取列的最大值和最小值
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
我需要的是以当前搜索的最大价格获得产品。我试过类似
Product.search('', :select => 'MAX(price)')
但它让我感到一团糟。
>> 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]
我真不明白它为什么这样做奇怪的查询,为什么它补充说,在哪里以及为什么它返回一个数组。
Regards, Franco。
谢谢帕特,我怀疑这是不可能的:)。 – 2013-04-09 15:31:59