<?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>Cory O&#039;Daniel - These are just words &#187; sphinx</title>
	<atom:link href="http://coryodaniel.com/index.php/tag/sphinx/feed/" rel="self" type="application/rss+xml" />
	<link>http://coryodaniel.com</link>
	<description>Software development, thoughts, and randomness</description>
	<lastBuildDate>Thu, 17 Nov 2011 21:18:05 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Thinking Sphinx cannot find Sphinx</title>
		<link>http://coryodaniel.com/index.php/2010/01/20/thinking-sphinx-cannot-find-sphinx/</link>
		<comments>http://coryodaniel.com/index.php/2010/01/20/thinking-sphinx-cannot-find-sphinx/#comments</comments>
		<pubDate>Wed, 20 Jan 2010 19:44:41 +0000</pubDate>
		<dc:creator>Cory O'Daniel</dc:creator>
				<category><![CDATA[RubyDevelopment]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[sphinx]]></category>
		<category><![CDATA[stupid human tricks]]></category>
		<category><![CDATA[thinking sphinx]]></category>

		<guid isPermaLink="false">http://coryodaniel.com/?p=417</guid>
		<description><![CDATA[I was getting this error this morning after setting up my new laptop for the project I am working on:

1
2
3
4
5
6
7
8
9
10
11
12
13
sh: line 1:   326 Trace/BPT trap          indexer 2&#62;&#38;1
sh: line 1:   329 Trace/BPT trap          /usr/local/bin/indexer [...]]]></description>
			<content:encoded><![CDATA[<p>I was getting this error this morning after setting up my new laptop for the project I am working on:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sh</span>: line <span style="color: #000000;">1</span>:   <span style="color: #000000;">326</span> Trace<span style="color: #000000; font-weight: bold;">/</span>BPT <span style="color: #7a0874; font-weight: bold;">trap</span>          indexer <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
<span style="color: #c20cb9; font-weight: bold;">sh</span>: line <span style="color: #000000;">1</span>:   <span style="color: #000000;">329</span> Trace<span style="color: #000000; font-weight: bold;">/</span>BPT <span style="color: #7a0874; font-weight: bold;">trap</span>          <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>indexer <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
&nbsp;
Sphinx cannot be found on your system. You may need to configure the following
settings <span style="color: #000000; font-weight: bold;">in</span> your config<span style="color: #000000; font-weight: bold;">/</span>sphinx.yml <span style="color: #c20cb9; font-weight: bold;">file</span>:
  <span style="color: #000000; font-weight: bold;">*</span> bin_path
  <span style="color: #000000; font-weight: bold;">*</span> searchd_binary_name
  <span style="color: #000000; font-weight: bold;">*</span> indexer_binary_name
&nbsp;
For <span style="color: #c20cb9; font-weight: bold;">more</span> information, <span style="color: #c20cb9; font-weight: bold;">read</span> the documentation:
http:<span style="color: #000000; font-weight: bold;">//</span>freelancing-god.github.com<span style="color: #000000; font-weight: bold;">/</span>ts<span style="color: #000000; font-weight: bold;">/</span>en<span style="color: #000000; font-weight: bold;">/</span>advanced_config.html
rake aborted<span style="color: #000000; font-weight: bold;">!</span>
uninitialized constant MysqlCompat::MysqlRes</pre></td></tr></table></div>

<p>Everyone probably knows this, but I wild-goose-chased trying to figure out if I had a setting wrong in my sphinx.yml file for Thinking Sphinx this morning for like half an hour before I realized what Thinking Sphinx meant about "Sphinx cannot be found on your system." was that the MySQL Development headers weren't installed.  I fixed this with a simple port install on Mac.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">port <span style="color: #c20cb9; font-weight: bold;">install</span> mysql5-devel</pre></td></tr></table></div>

<p>The more you know.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Thinking+Sphinx+cannot+find+Sphinx+http://coryodaniel.com/?p=417" title="Post to Twitter"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-twitter-big2.png" alt="Post to Twitter" /></a> <a class="tt" href="http://digg.com/submit?url=http://coryodaniel.com/index.php/2010/01/20/thinking-sphinx-cannot-find-sphinx/&amp;title=Thinking+Sphinx+cannot+find+Sphinx" title="Post to Digg"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-digg-big2.png" alt="Post to Digg" /></a> <a class="tt" href="http://www.facebook.com/share.php?u=http://coryodaniel.com/index.php/2010/01/20/thinking-sphinx-cannot-find-sphinx/&amp;t=Thinking+Sphinx+cannot+find+Sphinx" title="Post to Facebook"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-facebook-big2.png" alt="Post to Facebook" /></a> <a class="tt" href="http://reddit.com/submit?url=http://coryodaniel.com/index.php/2010/01/20/thinking-sphinx-cannot-find-sphinx/&amp;title=Thinking+Sphinx+cannot+find+Sphinx" title="Post to Reddit"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-reddit-big2.png" alt="Post to Reddit" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://coryodaniel.com/index.php/2010/01/20/thinking-sphinx-cannot-find-sphinx/&amp;title=Thinking+Sphinx+cannot+find+Sphinx" title="Post to StumbleUpon"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-su-big2.png" alt="Post to StumbleUpon" /></a></p>]]></content:encoded>
			<wfw:commentRss>http://coryodaniel.com/index.php/2010/01/20/thinking-sphinx-cannot-find-sphinx/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>DataMapper 0.10+ Basic Sphinx Support</title>
		<link>http://coryodaniel.com/index.php/2010/01/07/datamapper-0-10-basic-sphinx-support/</link>
		<comments>http://coryodaniel.com/index.php/2010/01/07/datamapper-0-10-basic-sphinx-support/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 22:18:26 +0000</pubDate>
		<dc:creator>Cory O'Daniel</dc:creator>
				<category><![CDATA[RubyDevelopment]]></category>
		<category><![CDATA[datamapper]]></category>
		<category><![CDATA[sphinx]]></category>

		<guid isPermaLink="false">http://coryodaniel.com/?p=415</guid>
		<description><![CDATA[I needed sphinx support and I needed it now. Apparently dm-sphinx-adapter wasn't ported to dm 0.10.  I started porting it, but I kind of felt like I was going down a rabbit whole.  I will continue to work on it over the next couple days, in the meantime at Vokle we used this [...]]]></description>
			<content:encoded><![CDATA[<p>I needed sphinx support and I needed it now. Apparently dm-sphinx-adapter wasn't ported to dm 0.10.  I started porting it, but I kind of felt like I was going down a rabbit whole.  I will continue to work on it over the next couple days, in the meantime at Vokle we used this to get our fulltext on. Note, this is doing the fulltext search across all columns in your fulltext index.  Its not doing cool matchers like :updated_at.gt yada-yada.  It also doesn't implement a DataMapper Adapter, its a super hack, but it gets the job done for us.</p>
<p>Give me your two cents and stay tuned for a full blown adapter.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">module</span> DataMapper
  <span style="color:#9966CC; font-weight:bold;">module</span> Model
    <span style="color:#9966CC; font-weight:bold;">def</span> sphinx_setup<span style="color:#006600; font-weight:bold;">&#40;</span>opts=<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>
      <span style="color:#0066ff; font-weight:bold;">@_sphinx_index</span> = opts<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:index</span><span style="color:#006600; font-weight:bold;">&#93;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> search<span style="color:#006600; font-weight:bold;">&#40;</span>_query_, opts=<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>
      sph_client = opts.<span style="color:#9900CC;">delete</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:client</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#6666ff; font-weight:bold;">Riddle::Client</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">*</span>SimpleSphinx.<span style="color:#9900CC;">conf</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      sph_client.<span style="color:#9900CC;">match_mode</span> = opts.<span style="color:#9900CC;">delete</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:match_mode</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#ff3333; font-weight:bold;">:extended</span>
&nbsp;
      sphinx_query = _query_.<span style="color:#9900CC;">to_s</span>.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#91;</span>\<span style="color:#006600; font-weight:bold;">&#40;</span>\<span style="color:#006600; font-weight:bold;">&#41;</span>\<span style="color:#006600; font-weight:bold;">|</span>\<span style="color:#006600; font-weight:bold;">-</span>!@~<span style="color:#996600;">&quot;&amp;<span style="color:#000099;">\/</span>]/){|char| &quot;</span>\\<span style="color:#008000; font-style:italic;">#{char}&quot;}</span>
&nbsp;
      results   = sph_client.<span style="color:#9900CC;">query</span><span style="color:#006600; font-weight:bold;">&#40;</span>sphinx_query, <span style="color:#0066ff; font-weight:bold;">@_sphinx_index</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">storage_names</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:default</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">to_sym</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      matches   = results<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:matches</span><span style="color:#006600; font-weight:bold;">&#93;</span>
      ids       = matches.<span style="color:#9900CC;">map</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>match<span style="color:#006600; font-weight:bold;">|</span> match<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:doc</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
      <span style="color:#008000; font-style:italic;"># Fetch</span>
      <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">all</span><span style="color:#006600; font-weight:bold;">&#40;</span>opts.<span style="color:#9900CC;">merge</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#123;</span>:id <span style="color:#006600; font-weight:bold;">=&gt;</span> ids<span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</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;">class</span> SimpleSphinx
  <span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#0000FF; font-weight:bold;">self</span>
    <span style="color:#9966CC; font-weight:bold;">def</span> conf
      <span style="color:#006600; font-weight:bold;">&#91;</span>server, port<span style="color:#006600; font-weight:bold;">&#93;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">def</span> server=<span style="color:#006600; font-weight:bold;">&#40;</span>s<span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#0066ff; font-weight:bold;">@_server</span> = s
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> port=<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0066; font-weight:bold;">p</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#0066ff; font-weight:bold;">@_port</span> = <span style="color:#CC0066; font-weight:bold;">p</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">def</span> server
      <span style="color:#0066ff; font-weight:bold;">@_server</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#996600;">'localhost'</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">def</span> port
      <span style="color:#0066ff; font-weight:bold;">@_port</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#006666;">3312</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>Wanna use it?</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># Your Model here</span>
Person.<span style="color:#9900CC;">sphinx_setup</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:index</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;indexName&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#008000; font-style:italic;">#defaults to storage name</span>
SimpleSphinx.<span style="color:#9900CC;">server</span> = <span style="color:#996600;">&quot;example.com&quot;</span>
SimpleSphinx.<span style="color:#9900CC;">port</span> = <span style="color:#006666;">3312</span>
&nbsp;
Person.<span style="color:#9900CC;">search</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;cory&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#008000; font-style:italic;">#=&gt; DataMapper::Collection</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># you can pass an additional hash of stuff you would pass to Model#all and this will be used to filter</span>
<span style="color:#008000; font-style:italic;"># the result set down POST sphinx when its collecting data from datamapper</span>
Person.<span style="color:#9900CC;">search</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;cory&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:limit</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">10</span>, <span style="color:#ff3333; font-weight:bold;">:gender</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:male</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

<p>You've got your sphinxter back. Congrats!</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=DataMapper+0.10%2B+Basic+Sphinx+Support+http://coryodaniel.com/?p=415" title="Post to Twitter"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-twitter-big2.png" alt="Post to Twitter" /></a> <a class="tt" href="http://digg.com/submit?url=http://coryodaniel.com/index.php/2010/01/07/datamapper-0-10-basic-sphinx-support/&amp;title=DataMapper+0.10%2B+Basic+Sphinx+Support" title="Post to Digg"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-digg-big2.png" alt="Post to Digg" /></a> <a class="tt" href="http://www.facebook.com/share.php?u=http://coryodaniel.com/index.php/2010/01/07/datamapper-0-10-basic-sphinx-support/&amp;t=DataMapper+0.10%2B+Basic+Sphinx+Support" title="Post to Facebook"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-facebook-big2.png" alt="Post to Facebook" /></a> <a class="tt" href="http://reddit.com/submit?url=http://coryodaniel.com/index.php/2010/01/07/datamapper-0-10-basic-sphinx-support/&amp;title=DataMapper+0.10%2B+Basic+Sphinx+Support" title="Post to Reddit"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-reddit-big2.png" alt="Post to Reddit" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://coryodaniel.com/index.php/2010/01/07/datamapper-0-10-basic-sphinx-support/&amp;title=DataMapper+0.10%2B+Basic+Sphinx+Support" title="Post to StumbleUpon"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-su-big2.png" alt="Post to StumbleUpon" /></a></p>]]></content:encoded>
			<wfw:commentRss>http://coryodaniel.com/index.php/2010/01/07/datamapper-0-10-basic-sphinx-support/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

