<?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>Frenzic Mojo &#187; plugins</title>
	<atom:link href="http://www.frenzicmojo.net/tag/plugins/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.frenzicmojo.net</link>
	<description>A boy and his blog</description>
	<lastBuildDate>Tue, 10 Nov 2009 04:29:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The Joys of Open Source</title>
		<link>http://www.frenzicmojo.net/2009/04/the-joys-of-open-source/</link>
		<comments>http://www.frenzicmojo.net/2009/04/the-joys-of-open-source/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 16:41:37 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[db_free_solr]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.frenzicmojo.net/?p=64</guid>
		<description><![CDATA[A while back, I tweeted about how cool it was to have a software patch I submitted be accepted.
You know what&#8217;s cooler than that?
Realizing that someone is actually using a plugin I wrote.
I mean, working with open source, when you put something like that out there, it&#8217;s with the idea that people will use it. [...]]]></description>
			<content:encoded><![CDATA[<p>A while back, I tweeted about how cool it was to have a software patch I submitted be accepted.</p>
<p>You know what&#8217;s cooler than that?</p>
<p>Realizing that someone is actually <a href="http://coderkitty.sweetperceptions.com/2009/3/27/removing-out-of-sync-error-in-acts_as_solr">using a plugin I wrote</a>.</p>
<p>I mean, working with open source, when you put something like that out there, it&#8217;s with the idea that people will use it. But having the idea is a lot different from the realization that someone you&#8217;ve never met half way around the world found something you did to be useful.</p>
<p>Edited to add: I just realized that it might not be obvious from the link, but I&#8217;m talking about the db_free_solr plugin.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.frenzicmojo.net/2009/04/the-joys-of-open-source/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Backgrounding acts_as_solr</title>
		<link>http://www.frenzicmojo.net/2009/04/backgrounding-acts-as-solr/</link>
		<comments>http://www.frenzicmojo.net/2009/04/backgrounding-acts-as-solr/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 16:36:14 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[acts_as_solr]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[solr]]></category>
		<category><![CDATA[workling]]></category>

		<guid isPermaLink="false">http://www.frenzicmojo.net/?p=54</guid>
		<description><![CDATA[I know, I know. No one uses Solr anymore. Except me. And the guy that maintains acts_as_solr. And all those people who talk about it on twitter. Okay, so there are still a few people using it. This is for them.
Just a quick note on how you can improve your user&#8217;s browsing experience in an [...]]]></description>
			<content:encoded><![CDATA[<p>I know, I know. No one uses Solr anymore. Except me. And the guy that <a href="http://github.com/mattmatt/acts_as_solr/tree/master">maintains acts_as_solr</a>. And all those people who talk about it on <a href="http://search.twitter.com/search?q=solr">twitter</a>. Okay, so there are still a few people using it. This is for them.</p>
<p>Just a quick note on how you can improve your user&#8217;s browsing experience in an app that uses acts_as_solr. Our app has been using acts_as_solr for a year or more now, and we&#8217;ve generally been happy with it. Re-indexing a big table can be painful, but we don&#8217;t really end up doing that very often.</p>
<p>The one area that was still causing us some pain was the inline indexing of objects. I think the standard solution for this issue has been to defer indexing when creating/updating/deleting and have a cron job scheduled to take care of it at regular intervals. And that both works and is relatively painless. But that solution negates one of the things I like about acts_as_solr, as compared to other search solutions, which is the fact that indexing can be real time.</p>
<p>Anyway, I&#8217;m getting a little long winded, all I wanted to do here was point out something that, in retrospect, might seem obvious to others.</p>
<p>Recently, for reasons unrelated to Solr, we implemented workling and starling so that we could background some tasks that were delaying (and in some cases, timing out) our users&#8217; sessions. While I was working on it, I realized that we could use workling to background the inline solr indexing, allowing us to speed up save operations while still basically having real time indexing. Here&#8217;s how we did it (all of this assumes that you have workling installed and functioning):</p>
<p>First, we created app/workers/solr_worker.rb:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> SolrWorker <span style="color:#006600; font-weight:bold;">&amp;</span>lt; <span style="color:#6666ff; font-weight:bold;">Workling::Base</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> index_object<span style="color:#006600; font-weight:bold;">&#40;</span>options=<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    object = options<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:object_type</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">constantize</span>.<span style="color:#9900CC;">find_by_id</span><span style="color:#006600; font-weight:bold;">&#40;</span>options<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:object_id</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">unless</span> object.<span style="color:#9900CC;">blank</span>?
      object.<span style="color:#9900CC;">solr_save</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> destroy_object_index<span style="color:#006600; font-weight:bold;">&#40;</span>options=<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    object = options<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:object_type</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">constantize</span>.<span style="color:#9900CC;">find_by_id</span><span style="color:#006600; font-weight:bold;">&#40;</span>options<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:object_id</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">unless</span> object.<span style="color:#9900CC;">blank</span>?
      object.<span style="color:#9900CC;">solr_destroy</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Next, in vendor/plugins/acts_as_solr/lib/instance_methods.rb, we added two methods:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> async_solr_save
  SolrWorker.<span style="color:#9900CC;">async_index_object</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:object_type</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9966CC; font-weight:bold;">class</span>.<span style="color:#9900CC;">name</span>, <span style="color:#ff3333; font-weight:bold;">:object_id</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">id</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> async_solr_destroy
  SolrWorker.<span style="color:#9900CC;">async_destroy_object_index</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:object_type</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9966CC; font-weight:bold;">class</span>.<span style="color:#9900CC;">name</span>, <span style="color:#ff3333; font-weight:bold;">:object_id</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">id</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>And, finally, in vendor/plugins/acts_as_solr/lib/acts_methods.rb, we changed two lines from this:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">after_save    <span style="color:#ff3333; font-weight:bold;">:solr_save</span>
after_destroy <span style="color:#ff3333; font-weight:bold;">:solr_destroy</span></pre></div></div>

<p>To this:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">after_save    <span style="color:#ff3333; font-weight:bold;">:async_solr_save</span>
after_destroy <span style="color:#ff3333; font-weight:bold;">:async_solr_destroy</span></pre></div></div>

<p>And that&#8217;s it. This solution has been in place for a couple of weeks now, and we&#8217;ve seen a real improvement.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.frenzicmojo.net/2009/04/backgrounding-acts-as-solr/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
