<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Wylie &#187; search</title>
	<atom:link href="http://www.wyliethomas.com/blog/tag/search/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.wyliethomas.com/blog</link>
	<description>web consultant.developer.angler</description>
	<lastBuildDate>Wed, 07 Dec 2011 18:14:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Reindexing Ferret</title>
		<link>http://www.wyliethomas.com/blog/2008/11/24/reindexing-ferret/</link>
		<comments>http://www.wyliethomas.com/blog/2008/11/24/reindexing-ferret/#comments</comments>
		<pubDate>Mon, 24 Nov 2008 18:05:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[acts_as_ferret]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[search]]></category>

		<guid isPermaLink="false">http://www.wyliethomas.com/2008/11/24/reindexing-ferret/</guid>
		<description><![CDATA[Its really simple, wished I had seen this part of the documentation a couple months ago.
Lesson learned. As the databse was being updated more often and becoming very large, indexing became more difficult to do just by doing a search in the browser. Back to the documentation and there it was.
script/console
&#62;&#62;MyModel.rebuild_index
Plus, the indexing seems to [...]]]></description>
			<content:encoded><![CDATA[<p>Its really simple, wished I had seen this part of the documentation a couple months ago.</p>
<p>Lesson learned. As the databse was being updated more often and becoming very large, indexing became more difficult to do just by doing a search in the browser. Back to the documentation and there it was.</p>
<p>script/console</p>
<p>&gt;&gt;MyModel.rebuild_index</p>
<p>Plus, the indexing seems to be much faster. Looking into  running the DRb server. Im worried about taking a performance hit. I&#8217;ll post what I learn when I try it out</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wyliethomas.com/blog/2008/11/24/reindexing-ferret/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building site search with Ferret</title>
		<link>http://www.wyliethomas.com/blog/2008/07/25/building-site-search-with-ferret/</link>
		<comments>http://www.wyliethomas.com/blog/2008/07/25/building-site-search-with-ferret/#comments</comments>
		<pubDate>Fri, 25 Jul 2008 20:07:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[acts_as_ferret]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[search]]></category>

		<guid isPermaLink="false">http://www.wyliethomas.com/2008/07/25/building-site-search-with-ferret/</guid>
		<description><![CDATA[I recently had the opportunity to build a search feature using the Ferret project.
So I wanted to document what I learned while it was still fresh in mind. First, getting Ferret and acts_as_ferret installed was pretty simple and straight forward. This blog post got me off to a good start.
The first index it created was [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had the opportunity to build a search feature using the Ferret project.</p>
<p>So I wanted to document what I learned while it was still fresh in mind. First, getting Ferret and acts_as_ferret installed was pretty simple and straight forward. <a href="http://www.railsenvy.com/2007/2/19/acts-as-ferret-tutorial" target="_blank">This blog post</a> got me off to a good start.</p>
<p>The first index it created was ok but I was looking for more relevant results. The boost option made the difference I was looking for. Here is how I set it up in my model.</p>
<p>#use acts_as_ferret plug in to assist in creating the index<br />
acts_as_ferret :fields =&gt; { :main_tags        =&gt; { :boost =&gt; 4, :store =&gt; :yes },<br />
:description      =&gt; { :boost =&gt; 2 },<br />
:keywords         =&gt; { :boost =&gt; 1, :store =&gt; :yes }, #have to add store =&gt; yes for lazy to work<br />
:photo_code       =&gt; { :boost =&gt; 1 },<br />
}</p>
<p>The production server has over 230k records in it. It took over 6 hours to index everything&#8230; (im still working out how to speed that up)&#8230; so for development I started with just a few hundred records. That only took a couple of minutes to index.</p>
<p>Once I had my index done I was ready to search it.</p>
<p>search_string = params[:search_term]</p>
<p>@results = Photo.find_by_contents(search_string, :limit =&gt; 50) #defaults to 10 results</p>
<p>(pagination notes are coming in a later post)</p>
<p>One of the unique requirements of this project was the need to refine the search on a specific set of keywords. For example, we need to know how many of the search results are also tagged with age, gender or ethnic keywords. So, to know how many of the search results are also tagged with &#8220;Mid Adult Women (2,544) &#8221; I used the lazy method in ferret to spare a hit to the database for it. Going to the database for these refine search options put page loads over 10 seconds, 20+ seconds in some cases. Since that is completely unacceptable, Im glad the Ferret team came up with :lazy. It may have saved my job <img src='http://www.wyliethomas.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Photo.find_by_contents(search_string + &#8221; AND Mid Adult Women&#8221;, {:lazy =&gt; [:keywords]}).total_hits</p>
<p>I learned that find_by_contents will ignore the :condition option for extra query info. But, you can do multiple AND OR statements as part of the search string. Now I can refine my search many times over without ever touching the database!</p>
<p>In the end I am searching over 230k records getting as much as 20k results on some searches and showing total_hits on over 60 refine search options in less than .4 seconds with only one hit to the database. Pretty cool.</p>
<p>Next is pagination</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wyliethomas.com/blog/2008/07/25/building-site-search-with-ferret/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

