Take the 2-minute tour ×

I have a list of items with different categories. An item could be in multiple categories, so I have 3 tables: items / categories / connections

I need to filter / count the search results:

  • category1 (100 items)

  • category2 (90 items)

  • category3 (80 items)

  • etc.


share|improve this question
add comment

1 Answer

I recently made this


which is a documented example doing pretty much what you ask.

share|improve this answer
btw, this answer is about creating the front end. It assumes you already have a working index, with the category stored in an attribute. Do you? Also just realised you said can be in multiple categories. Which complicates matters slightly. The example doest cope with MVAs –  barryhunter Oct 16 '12 at 11:39
I found an example that seems to be similar with my needs and is also solved by you :) sphinxsearch.com/forum/view.html?id=6805 –  drn Oct 16 '12 at 12:03
I used group_id with ord to apply the filter in the category page. Exists the posibility tu use SetGroupBy with ord? In need it for the side categories counts. In this context: $counts = array(); foreach ($res['matches'] as $doc_id => $row) { $counts[$row['attrs']['@groupby']] = $row['attrs']['@count']; } $ids = array_keys($counts); –  drn Oct 16 '12 at 15:57
add comment

Your Answer


