views:

64

answers:

0

I'm trying to use Thinking Sphinx for my Product model. It is also translated with Globalize2. Which makes a bit of a problem. Because obviously, no straightforward approach like this

class Product < ActiveRecord::Base
    translates :title, :description
    define_index do
        indexes :title, :description
    end
end

would work since there is no title and description columns in products table. Besides, it doesn't take locale into account. However, transformed into something like this:

class Product < ActiveRecord::Base
    translates :title, :description
    has_many :product_translations # ugly, but what else can I do?
    define_index do
        indexes [product_translations.title, product_translations.description], :as => :content
        has product_translations.locale, :as => :locale
    end
end

it should in theory start working. But it doesn't. Bare

Product.search

returns all products, but

Product.search 'a'

for instance doesn't return any. Although there are products with 'a' in title and/or description.

Any thoughts why?