Dynamic Faceting With Thinking Sphinx

25 views
Skip to first unread message

Abhishek jain

unread,
Jul 21, 2014, 8:39:50 AM7/21/14
to thinkin...@googlegroups.com
Hi,

In my project I need a functionality based on dynamic faceting. 

Something like:

Lets say we have 4 models product, variants, option types and option values

OptionType has_many => option_values
Variant has_many => option_values
Product has_many => option_types
Product has_many => variants

I need to facet option type having its facet values as option_values
And option values are linked with product objects.

Example.

Color (Option Type)
  -> Red (Option Value)
  -> Green (Option Value)
  -> Blue (Option Value)

Product has option type Color and variant has option value as Red.
Hence faceted value should be

Color
- Red (1)

Now, when I add another option type, lets say Size.
with option values.
Size (Option Type)
  -> L (Option Value)
  -> XL (Option Value)
  -> XXL (Option Value)

And link Size with product and XL with one of the variant, then

Result should be something like,

Color
- Red(1)
- Green(0)
- Blue(0)

Size
- L (0)
- XL (1)
- XXL (0)

Is it possible to do this with ThinkingSphinx? 

Pat Allan

unread,
Jul 26, 2014, 12:59:04 PM7/26/14
to thinkin...@googlegroups.com
I don’t think anything like this is possible, I’m afraid. Sphinx faceting is done by grouping on attributes, so you’d need each facet to be defined as an attribute, which means you need to know what they are when configuring Sphinx.

Also, Sphinx has no concept of a hash/dictionary data type, so for a Product, you couldn’t have option types have option values, let alone distinguish between them on a variant level. That said, you could search on OptionType instead… but you still have the above issue to deal with.

For reference, it’s worth noting that Sphinx has an inbuilt FACET function from 2.2.3 (2.2.x releases are considered betas):
But that doesn’t address the issue I’ve covered.

One thing that *might* help - it’d require some investigation, though - is the JSON support in Sphinx since version 2.1.1-beta:
I’ve not really played with it, but maybe that would allow the types of queries you need to group by specific values, if a Product or Variant’s option types and option values are stored as JSON in Sphinx? This is probably the only path worth investigating, but I can’t guarantee if it’ll work or not.

— 
Pat

--
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 thinking-sphi...@googlegroups.com.
To post to this group, send email to thinkin...@googlegroups.com.
Visit this group at http://groups.google.com/group/thinking-sphinx.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages