# How to apply the :group\_by option in ferret search

**URL:** <https://www.ruby-forum.com/t/how-to-apply-the-group-by-option-in-ferret-search/136151>\
**Category:** Rails\
**Created:** [April 29, 2008, 12:49pm UTC](https://www.ruby-forum.com/t/how-to-apply-the-group-by-option-in-ferret-search/136151 "2008-04-29T12:49:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vicky](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b19c9b/32.png) [@vicky](https://www.ruby-forum.com/u/vicky)\
**Post date:** [April 29, 2008, 12:49pm UTC](https://www.ruby-forum.com/t/how-to-apply-the-group-by-option-in-ferret-search/136151/1 "2008-04-29T12:49:48Z")

</div>

Please help its urgent.

---

<div class="post-metadata">

**Author:** ![vicky](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b19c9b/32.png) [@vicky](https://www.ruby-forum.com/u/vicky)\
**Post date:** [August 27, 2008, 12:03am UTC](https://www.ruby-forum.com/t/how-to-apply-the-group-by-option-in-ferret-search/136151/2 "2008-08-27T00:03:00Z")

</div>

vicky wrote:

> Please help its urgent.

Object.find\_with\_ferrey(‘some keywords …’, {}, {:group=\>:column\_field,  
:conditions=\>“1=1”})

the 1st empty {} is for ferret options, with can be :page and :per\_page

the 2nd {}, can put any find option

This one will be fine with grouping, but you must add 1 line to

vendor/plugins/acts\_as\_ferret/lib/class\_method.rb

def count\_records(id\_arrays, find\_options = {})  
…  
opts = find\_options.merge :conditions =\> conditions  
opts.delete :limit; opts.delete :offset  
#----add this line or else it gonna cause error with group option  
opts.delete :group  
#----end of adding line  
count += model.count opts  
…  
end
