Does this in your index definition do the trick? has option_types.id, :as => :option_type_ids, :facet => true has variants.option_values.id, :as => :option_value_ids, :facet => true
I've used primary keys instead of any string values, because Sphinx doesn't allow for multi-value string attributes. You'll need to translate between ids and objects yourself. Here's some code I put together for a project I worked on that does something similar - perhaps it's a useful starting point: https://gist.github.com/pat/5477820 -- Pat On 7 Feb 2014, at 5:10 pm, Abhishek jain <[email protected]> wrote: > I am using thinking_sphinx v3.0.5. > > I need to create facets with has_many through relation. > > Like > > class Product < ActiveRecord::Base > has_many :variants > has_many :option_types > end > > class Variant < ActiveRecord::Base > has_and_belongs_to_many :option_values > belongs_to :product > end > > class OptionType < ActiveRecord::Base > has_many :option_values > belongs_to :product > end > > > class OptionValue < ActiveRecord::Base > has_and_belongs_to_many :variants > belongs_to :option_type > end > > > > I need to create facets on products for option_type as facet and option > values based on its variants as its values? > > Is it possible to do this? Or how can I proceed with it? > > -- > 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/groups/opt_out. -- 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/groups/opt_out.
