Hi Miha

While Sphinx can have arrays of integers, it can’t have arrays of floats - and 
even if it could, there’s no link between one item in one array (e.g. a price) 
and one item in another array (e.g. a currency).

The best approach here is to add a Sphinx index for AdPrice, and search from 
that perspective instead.

  AdPrice.search :with => {
    :currency_id => params[:c_currency_id].to_i,
    :price       => params[:price_from].to_f..params[:price_to].to_f
  }

Cheers

— 
Pat

> On 15 May 2015, at 2:04 am, Treeninja <[email protected]> wrote:
> 
> Hi guys!
> 
> I am using TS 2.0.
> 
> I have an Ad which has many prices, all in different currency. I am using 
> Fixer API to convert a price to other prices and store them in DB. I would 
> like to index column price and currency_id from the ad_prices table:
> 
> #  id            :integer          not null, primary key
> #  ad_id :integer
> #  currency_id   :integer
> #  price         :decimal(8, 2)
> #  is_up_or_down :integer
> #  is_default    :boolean          default(FALSE)
> #  created_at    :datetime         not null
> #  updated_at    :datetime         not null
> 
> In the ad model I have define_index section:
> 
>     has ad_prices.price, :as => :price, :type => :float
>     has ad_prices.currency_id, :as => :c_currency_id
> 
> How can I force the sphinx to use combination of prices and currencies at the 
> same time. For example if user sets param[c_currency_id]=1, how can sphinx 
> filter only the prices in selected currency? I have a range filter for 
> prices: price_from, price_to, c_curency_id
> 
> Thank you very much for the support!
> 
> Kind regards, Miha
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Thinking Sphinx" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/thinking-sphinx.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/thinking-sphinx.
For more options, visit https://groups.google.com/d/optout.

Reply via email to