<?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>Swarling Black Mable &#187; Search Optimizations</title>
	<atom:link href="http://blainegarrett.com/category/programming/search-optimizations/feed/" rel="self" type="application/rss+xml" />
	<link>http://blainegarrett.com</link>
	<description>Blaine Garrett's Home on the Web - Art, Programming, Ideas, and more</description>
	<lastBuildDate>Tue, 02 Aug 2011 18:50:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Building &#8220;Tag Cloud&#8221; in Rails</title>
		<link>http://blainegarrett.com/2007/09/28/building-tag-cloud-in-rails/</link>
		<comments>http://blainegarrett.com/2007/09/28/building-tag-cloud-in-rails/#comments</comments>
		<pubDate>Fri, 28 Sep 2007 06:44:35 +0000</pubDate>
		<dc:creator>blainegarrett</dc:creator>
				<category><![CDATA[Adamantine Arts]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Search Optimizations]]></category>

		<guid isPermaLink="false">http://blainegarrett.com/blog/2007/09/28/building-tag-cloud-in-rails/</guid>
		<description><![CDATA[I am working on the new search engine for Adamantine Arts and wanted to display the top 25 queries. I thought it would be nice to display the searches in the cool tag cloud form where the more popular the search the larger the text. So quick tutorial on how to build a tag cloud [...]]]></description>
			<content:encoded><![CDATA[<p>I am working on the new search engine for Adamantine Arts and wanted to display the top 25 queries. I thought it would be nice to display the searches in the cool tag cloud form where the more popular the search the larger the text.</p>
<p>So quick tutorial on how to build a tag cloud in Rails. Hurray for logarithms lately. They are all over the search code.</p>
<p>Criteria :<br />
- Use percent based fonts to display size<br />
- Sizes  should be relative (high search popularity doesn&#8217;t make HUGE text)<br />
- Top 25  should be displayed randomly, even though we are sorting by the most popular.</p>
<p>So here goes:</p>
<p>In your controller, get your search:</p>
<pre class="brush: ruby">
@popular_searches = Search.find(:all, :limit =&amp;gt; 25, <img src='http://blainegarrett.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> rder =&amp;gt; &#039;popularity DESC&#039;)
@popular_searches = @popular_searches.sort_by { rand }
</pre>
<p>The last line shuffles/randomizes the entries even though we sorted by popularity.</p>
<p>Next for the view. The min/max could probably stand to be in the controller, but since it is just for display, I have no qualms putting it in the view.</p>
<pre class="brush: ruby">
&amp;lt;%
pmin = 100 # Minimum font size
pmax = 400 #Maximum font size
vmin = 10000000000000 #Super large number to init min
vmax = -1000000000000 #Super small number to init max
for search in @popular_searches
	if (search.popularity  vmax)
		vmax = search.popularity
	end
end
%&amp;gt;

&amp;lt;a href=&quot;/search/?q=&quot;
style=&quot;font-size:%&quot;
title=&quot;Search&quot;&amp;gt;&lt;/a&gt;
</pre>
<p>So the tag font size is a function of the min popularity, the max popularity, the maximum size, minimum size, and the popularity for the specific tag. This will generate you a nice little tag list.</p>
<p>Sources: <a href="http://blogoforum.com/tag/blogoforum+math+suggestion+tagcloud+tagging/tag-cloud-makeup-continued-3294.html" title="Math function for tag clouds" target="_blank">Tagging math</a>, <a href="http://www.ruby-forum.com/topic/92083" title="Randomizing Arrays in Ruby" target="_blank">randomizing Active Record set</a><br />
The finished product is in beta on the <a href="http://adamantinearts.org/search/" title="Site Search" target="_blank">Adamantine Arts search </a></p>
]]></content:encoded>
			<wfw:commentRss>http://blainegarrett.com/2007/09/28/building-tag-cloud-in-rails/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Interesting Google Tidbit</title>
		<link>http://blainegarrett.com/2007/09/05/interesting-google-tidbit/</link>
		<comments>http://blainegarrett.com/2007/09/05/interesting-google-tidbit/#comments</comments>
		<pubDate>Wed, 05 Sep 2007 17:12:48 +0000</pubDate>
		<dc:creator>blainegarrett</dc:creator>
				<category><![CDATA[Cyber Culture]]></category>
		<category><![CDATA[Search Optimizations]]></category>

		<guid isPermaLink="false">http://blainegarrett.com/blog/?p=12</guid>
		<description><![CDATA[I discovered a small thing today as I was checking this page&#8217;s ranking when searching for my own name. Go figure that middle names would screw up your placement&#8230; I really like my middle name &#8220;Flynn&#8221; and started including it on my business cards and such. When I redesigned this site last week, I added [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blainegarrett.com.digibodies.com/files/2007/09/googl.jpg" title="googl.jpg"><img src="http://blainegarrett.com.digibodies.com/files/2007/09/googl.jpg" alt="googl.jpg" style="width: 50%;float: right" /></a>I discovered a small thing today as I was checking this page&#8217;s ranking when searching for my own name. Go figure that middle names would screw up your placement&#8230;</p>
<p><span id="more-12"></span></p>
<p>I really like my middle name &#8220;Flynn&#8221; and started including it on my business cards and such.  When I redesigned this site last week, I added my middle name to all the spots where I was using my first and last name. But then when I checked my page rank for searches for &#8220;Blaine Garrett&#8221;, I could not longer even find this site.</p>
<p>However, when I searched for &#8220;Blaine Flynn Garrett&#8221;, &#8220;Blaine Flynn&#8221;, or &#8220;Flynn Garrett&#8221; this page came up in the top two results. This leads me to believe that the adjacency of words plays a role in results. Very odd.</p>
<p>As a result, I removed &#8220;Flynn&#8221; from all over the site. I figure people that will have my full name got it from a business card, etc and thus have the site address too. Otherwise, they got my name off of a gallery tag, forum post, word of mouth etc, and I want them to be able to easily find me. Now I just need GoogleBot to update&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blainegarrett.com/2007/09/05/interesting-google-tidbit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

