How can i index the sum of tow attributes with thinking sphinx?

i have option model with this structure:

Class Option < ActiveRecord::Base

has_one :base_price, :class_name => “OptionPrice”, :conditions =>
{:base => true}

define_index do
indexes base_price.provider_price, :as => :p_base_price
indexes base_price.margin_price, :as => :m_base_price
indexes “SUM(p_base_price, m_base_price)”, :as => :base_price
end

and in the controller i want to do :

@products = Option.search(params[:search], :conditions =>{:base_price
=> 15 } ,
:page => params[:page], :per_page => 2)
this is a wrong solution of course but i think any one can understand
what i want to do : searching products having base_price = 15
(base_price = provider_price + margin_price, which are OptionPrice
attributes)
How can i solve this issue , i’m using thinking_sphinx 2.0.3 and RAILS
3
Best Regards
thanks

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs