<?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>ben koonse &#187; ruby</title>
	<atom:link href="http://bennyfreshness.com/tag/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://bennyfreshness.com</link>
	<description>wrestling code into submission...</description>
	<lastBuildDate>Tue, 11 Oct 2011 19:38:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<item>
		<title>Sunspot Showed Me the Light</title>
		<link>http://bennyfreshness.com/2010/05/sunspot-showed-me-the-light/</link>
		<comments>http://bennyfreshness.com/2010/05/sunspot-showed-me-the-light/#comments</comments>
		<pubDate>Thu, 20 May 2010 07:06:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[solr]]></category>
		<category><![CDATA[sunspot]]></category>

		<guid isPermaLink="false">http://bennyfreshness.com/?p=151</guid>
		<description><![CDATA[Ladies and gentleman, gone are the dark ages of using SQL (a known gateway drug) to perform searches. Thats right, I&#8217;m here today to spotlight Sunspot, &#8220;a Ruby library for expressive, powerful interaction with the Solr search engine.&#8221; Ever since that fated column of light struck my monitor and forced my browser to google Solr, [...]]]></description>
			<content:encoded><![CDATA[<p>Ladies and gentleman, gone are the dark ages of using SQL (a known gateway drug) to perform searches.  Thats right, I&#8217;m here today to spotlight <a href="http://outoftime.github.com/sunspot/" target="_blank">Sunspot</a>, &#8220;a Ruby library for expressive, powerful interaction with the Solr search engine.&#8221;</p>
<p>Ever since that fated column of light struck my monitor and forced my browser to google <a href="http://lucene.apache.org/solr/" target="_blank">Solr</a>, I&#8217;ve had the strength to overcome my addiction to SQL searches.  Gone are the days of &#8220;select intervention_date from developers where search_method like &#8216;%sql%&#8217;&#8221;</p>
<p>Get out of that darkness cupcake! Let some light brighten up that dark and dreary world of murky sql search statements and enter a radiant and luminous world of vibrant Sunspot search!</p>
<p><span id="more-151"></span></p>
<p>We can get through this together&#8230;</p>
<p>Step 1: Installation</p>
<pre>
  gem install sunspot
  gem install sunspot_rails
</pre>
<p>Step 2: Define What to Index</p>
<pre>
  class Rehab
    #...
  end

  Sunspot.setup(Rehab) do
    text :addiction
    integer :relapses
    float :relapse_average
    time :admitted_at
    string :cure do
      addiction.gsub(/(darkness|clouds|shadows)/, 'sunshine')
    end
  end
</pre>
<p>Step 3: Search</p>
<pre>
  search = Sunspot.search Rehab do
    keywords 'light sunshine'
    with :patient_name, 'Benny Freshness'
    with(:relapses).any_of [2, 14]
    with(:relapse_average).less_than 4
    any_of do
      with(:admitted_at).less_than(Time.now)
    end
    without :cure, 'Moar SQL'
    order_by :average_relapse, :desc
    facet :cure
  end</pre>
<p>Step 4: Profit</p>
<p>In all cerealness, I&#8217;d like to shed light on the line &#8216;facet :cure&#8217; for a lightsecond as this really illuminates the vibrance of Sunspot.  A &#8220;<a href="http://wiki.apache.org/solr/SimpleFacetParameters" target="_blank">facet</a>&#8221; is a glint of search aurora.  Say my search lights up 45 results, by faceting on cure, we can get tallies of how many of each distinct cures are retuned in the result set e.g &#8216;moar SQL&#8217;:10, &#8216;Solr&#8217;:5, &#8216;Sunspot&#8217;:25, &#8216;Zippo&#8217;:1</p>
<p>By faceting we can irradiate our result set and re-kindle that old flame for search burning inside us all.</p>
<p>Furthermore, feast on these tasty Sunspot nuggets:</p>
<blockquote>
<ol>
<li>kindergarden easy index control</li>
<li>keyword search, ordering, scoping, awesomeing</li>
<li>indexing custom/dynamic field goodness</li>
<li>DSL which feels like your native toungue</li>
<li>faceting for days, CUSTOM FACETS!!</li>
<li>extensible, pick an ORM, any ORM</li>
<li>will_play with will_paginate</li>
<li>order by field value, relevance, geographical distance, or your face</li>
</ol>
</blockquote>
<p>Well folks, thats all I can illuminate for you here today.  Hopefully my annoying &#8220;light&#8221; analogies don&#8217;t have you plotting to kill me by now. I also hope I cast some light on something you might be able to use or find interesting.</p>
<p>So remember, use the force, don&#8217;t join the dark side of SQL searching, step into the magnificent light of Sunspot!</p>
]]></content:encoded>
			<wfw:commentRss>http://bennyfreshness.com/2010/05/sunspot-showed-me-the-light/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

