Number of results in group by

Raimond Garcia's Avatar

Raimond Garcia

26 Jul, 2014 03:04 PM

Hi Pat,

Is there a way to return more than one result when using a group_by clause?

This is what I have right now:[:query], group_by: :sphinx_internal_class)

Ideally I would like something like this:[:query], group_by: :sphinx_internal_class, max_results_per_group: 5)



  1. Support Staff 1 Posted by Pat Allan on 26 Jul, 2014 05:13 PM

    Pat Allan's Avatar

    Hi Rai

    A feature for this was added to Sphinx in v2.2.1, and it's in Thinking Sphinx v3.1.0 onwards, using the :group_best option: params[:query], group_by :sphinx_internal_class, :group_best => 5

    Currently, 2.2.3 is the only Sphinx 2.2.x release on the Flying Sphinx servers, so make sure you've got that set under the production settings in config/thinking_sphinx.yml - and of course, test it locally first :)



  2. 2 Posted by Raimond Garcia on 27 Jul, 2014 09:11 PM

    Raimond Garcia's Avatar

    Awesome Pat, works like a charm.

    Thank you!

  3. Support Staff 3 Posted by Pat Allan on 28 Jul, 2014 12:53 AM

    Pat Allan's Avatar

    Great :)

  4. Pat Allan closed this discussion on 28 Jul, 2014 12:53 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac