Group_by user_id

Hello,

I want to know if this is possible with sphinx.

Let’s say I have this table.

id | user_id | title

1 1 sphinx
6 1 sphinx
2 5 sphinx
3 5 sphinx
4 4 server
5 1 great

I want to group_by(user_id) and say at least 2 times occured in the
user_id for that specific title

Maybe something like this in Rails:
pages = Page.search(‘sphinx’, :group_by => ‘user_id’, :group_function =>
:attr, :group_clause => “@users desc”)

But I want something like this:
group_by(user_id) if @at_least_found_to_times

In the end I need this result.

user_ids | users | title

1,5 2 sphinx

Hope someone can direct me in any direction :smiley:

Thanks for any help.

With Rails or does sphinx handle the calculations all together?

Anton Anykeyev wrote in post #968296:

you can use any function in group_by clause, for example you can write
something like

your_record_collection.group_by{|zz|
function_returning_found_times}.each do |count_of_times, sub_collection|

next if count_of_times<SOME_VALUE #
user_ids = sub_collection.collect(&:user_id).join(’,’)
users_cnt = sub_collection.size

…etc

end

you can use any function in group_by clause, for example you can write
something like

your_record_collection.group_by{|zz|
function_returning_found_times}.each do |count_of_times, sub_collection|

next if count_of_times<SOME_VALUE #
user_ids = sub_collection.collect(&:user_id).join(’,’)
users_cnt = sub_collection.size

…etc

end