Custom Facets

115 views
Skip to first unread message

Ryan Bates

unread,
Mar 9, 2009, 7:33:33 PM3/9/09
to Thinking Sphinx
Thanks Pat for adding facet support to TS, but I could not find too
much documentation on it aside from this mailing list. I've got it
working great for simple values, but is it possible to add facets for
more complex scenarios?

Take price ranges for one example. Let's say we have many products
with varying prices, and we would like to provide the option to filter
by price groups.

Price
under $5 (20)
$5 to $10 (8)
$10 to $20 (13)
$20 to $50 (54)
more than $50 (3)

An even more complex scenario is that products have many reviews
(separate table), each with a 1-5 star rating. We would like to
average up the rating for each product and filter based on that.

Rating
Not Rated (10)
1 star (3)
2 stars (8)
3 stars (27)
4 stars (48)
5 stars (21)

Does the built in facets provide an easy way to do this kind of thing?
If not, do you recommend I bypass the current facets support and
implement my own way for doing this at a lower level?

Pat Allan

unread,
Mar 10, 2009, 9:09:43 AM3/10/09
to thinkin...@googlegroups.com
Hi Ryan

I'm afraid I can't help you at the moment - TS's facet support isn't
that complex, and I'm not sure if Ultrasphinx's is any better, for
what you want. You're not the first to request ranged facets, so it's
definitely on my radar, but I'm struggling to find time even to polish
up the current facet code.

If you want to hack something together, that'd be fantastic. If you
just need something to run with right now, then Solr might be the
better option - I think it has ranged facet support.

Cheers

--
Pat

Mickaël

unread,
Mar 10, 2009, 9:37:29 AM3/10/09
to Thinking Sphinx
Hi,

Currently I'm working with Facets. Like Ryan said, I working with
complex facets scenario.

Searching in my website with filter.

Facets list me : last_name and first_name.

last_name (7)
* Zebulon (3)
* ALLAIN (2)
* ALLAINooooo (1)
* Sander (1)
* Ungant (1)
* Zabbuli (2)
* Zebruska (1)

First_name(7)
* Pierre (4)
* Mickaël (2)
* Arnaud (1)
* Blanchard (1)
* Elodie (1)
* Pierrot (1)
* zezeze (1)

When I'm clicking on Last_name "Zebulon", my content searches is
refresh and first_name is up to date too like :

First_name(3)
* Blanchard (1)
* Elodie (1)
* Mickaël (1)

Currently, facets doesn't support has_many, and I hope this feature
will be released with your work.

Cheers,

Mickaël.

Ryan Bates

unread,
Mar 10, 2009, 12:52:27 PM3/10/09
to Thinking Sphinx
Thanks Pat. I'll attempt to get this working through some hacking and
post my findings back here.

Ryan

Ryan Bates

unread,
Mar 13, 2009, 5:37:54 PM3/13/09
to Thinking Sphinx
I determined this problem is difficult to solve through Sphinx because
it indexes directly from the database. While this definitely offers a
speed benefit, it makes it difficult to do custom attribute indexing
without filling up the database with many extra columns and dealing
with syncing issues.

I ended up using Xapian which offers a nice indexing solution through
its Ruby bindings. This allows me to index custom values for the
facets. True, the indexing is slower, but for me this is not a
problem.

For those interested, check out the library I'm building to accomplish
this (called Xapit) here:
http://github.com/ryanb/xapit/tree/master

Regards,

Ryan
Reply all
Reply to author
Forward
0 new messages