# Most frequent searched query string - Ferret

**URL:** <https://www.ruby-forum.com/t/most-frequent-searched-query-string-ferret/196770>\
**Category:** Rails\
**Created:** [August 4, 2008, 9:01am UTC](https://www.ruby-forum.com/t/most-frequent-searched-query-string-ferret/196770 "2008-08-04T09:01:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sgudibanda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9adbd/32.png) [@sgudibanda](https://www.ruby-forum.com/u/sgudibanda)\
**Post date:** [August 4, 2008, 9:01am UTC](https://www.ruby-forum.com/t/most-frequent-searched-query-string-ferret/196770/1 "2008-08-04T09:01:23Z")

</div>

Hi,

I need to calculate most frequent searches on a particular model. I am  
using ferret for searching in full text mode.

For eg: Search on hospital names. I have a form which allows user to  
enter a search query, and underneath ferret does the search and provides  
the results.

Now, I would like to show the user, some previous search related data  
like Most frequent/popular search data.How can i do that? Does ferret  
have any inbuilt mechanism for this or do I have to build my own. Please  
suggest on ideas as well.

Regards,  
SG

---

<div class="post-metadata">

**Author:** ![sgudibanda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9adbd/32.png) [@sgudibanda](https://www.ruby-forum.com/u/sgudibanda)\
**Post date:** [August 4, 2008, 9:21am UTC](https://www.ruby-forum.com/t/most-frequent-searched-query-string-ferret/196770/2 "2008-08-04T09:21:33Z")

</div>

Hi Sandeep,

On 4 Sie, 09:01, Sandeep G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> like Most frequent/popular search data.How can i do that? Does ferret  
> have any inbuilt mechanism for this or do I have to build my own. Please  
> suggest on ideas as well.

If “most frequently searches” are not dependent on user who is  
searching,  
I mean: these are not user’s most frequenlty searches, then why don’t  
you  
go with simple integer field in your model that gets increased every  
time record  
gets listed in search results?

---

<div class="post-metadata">

**Author:** ![sgudibanda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9adbd/32.png) [@sgudibanda](https://www.ruby-forum.com/u/sgudibanda)\
**Post date:** [August 4, 2008, 9:30am UTC](https://www.ruby-forum.com/t/most-frequent-searched-query-string-ferret/196770/3 "2008-08-04T09:30:41Z")

</div>

I was only hoping Ferret will have some mechanism to keep track of  
searched keywords, based on which it can specify what is the most  
searched keyword.

If i have to do manually , i will have to modify multiple rows that were  
found in database for every search. Is this the normal way of doing it?

Also, since i do paginate of the results, i end up updating only a few  
rows though all other rows also figure in search results.

Regards,  
SG

---

<div class="post-metadata">

**Author:** ![sgudibanda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9adbd/32.png) [@sgudibanda](https://www.ruby-forum.com/u/sgudibanda)\
**Post date:** [August 4, 2008, 2:46pm UTC](https://www.ruby-forum.com/t/most-frequent-searched-query-string-ferret/196770/4 "2008-08-04T14:46:43Z")

</div>

You could model your search as it own resource. Instead of hacking up  
your existing tables, you would just save the search terms in the  
search model and use the index view to list previous searches and the  
show view to run them again.

Chris B  
[http://www.randomutterings.com](http://www.randomutterings.com)

On Aug 4, 3:30 am, Sandeep G. \<rails-mailing-l…@andreas-
