<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[HarmsSite]]></title>
  
  <link href="http://harmssite.com/" />
  <updated>2013-05-01T09:21:16-05:00</updated>
  <id>http://harmssite.com/</id>
  <author>
    <name><![CDATA[Tyler Harms]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/Harmssite" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="harmssite" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry>
    <title type="html"><![CDATA[Symfony2 Coding Standards]]></title>
    <link href="http://harmssite.com/2013/04/symfony2-coding-standards/" />
    <updated>2013-04-30T13:30:00-05:00</updated>
    <id>http://harmssite.com/2013/04/symfony2-coding-standards</id>
    <content type="html"><![CDATA[<p>With eZ Publish moving to Symfony2, I found that I was in need of learning some new coding standards. I never really looked into PHP CodeSniffer while doing eZ Publish development (most of my code was in the templates), so I never really thought about PHP CodeSniffer as an option until starting work with Symphony2. To the point, I just wanted to share the <a href="https://github.com/opensky/Symfony2-coding-standard">Symfony2 PHP CodeSniffer Coding Standard on Github</a>. It is really easy to install and because phpcs works with PHPStorm and Sublime Text 2, sniffing out php files couldn&#8217;t be easier.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[New Site Theme]]></title>
    <link href="http://harmssite.com/2013/04/new-site-theme/" />
    <updated>2013-04-15T08:39:00-05:00</updated>
    <id>http://harmssite.com/2013/04/new-site-theme</id>
    <content type="html"><![CDATA[<p>I have been working on getting a new site theme up and running for a while now. My hold up was that I could never commit to a platform. I knew that I wanted off Wordpress and onto something more developer friendly. Originally I was going to put this site on eZ Publish, but that just seemed like overkill. Next I thought about creating a Symfony2 blog, but I wanted to cheapen my hosting options so I opted against Symfony2. I finally decided upon Rails, hosted on the free tier of Heroku.</p>

<p>I was in the middle of development when I discovered Octopress. How I had never heard of this platform before, I don&#8217;t know. In under 4 hours total I had my Wordpress site migrated off of Wordpress and onto a Github Pages site generated by Octopress; it was a very smooth transition. Because development was so fast, I opted to stick with Octopress and <a href="http://octopress.org/docs/deploying/github/" title="Deploying to GH-Pages">GH-Pages</a>.</p>

<p>My site is now running statically using Octopress as a site generator and Github as a free host. Octopress is built on Jekyll, so I can make plugins easily (in Ruby) as well as pull in any existing plugin with ease. Octopress seems like it is built to be <strong>the</strong> developer blogging platform. The code blocks, the post generation, and the fact that it is built on Ruby all helped me settle on Octopress as my new blogging platform. I hope you enjoy the new site!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Start Searching with Solr - Integrating Solr into any PHP project is easy with Solarium [REPOST]]]></title>
    <link href="http://harmssite.com/2013/03/start-search-with-solr-integrating-solr-into-any-php-project-is-easy-with-solarium-repost/" />
    <updated>2013-03-15T00:00:00-05:00</updated>
    <id>http://harmssite.com/2013/03/start-search-with-solr-integrating-solr-into-any-php-project-is-easy-with-solarium-repost</id>
    <content type="html"><![CDATA[<p style="text-align:center;">This post is a repost of an article I wrote for <a title="Web and PHP Magazine" href="http://webandphp.com/" target="_blank">Web and PHP Magazine</a>&#8217;s <a title="Web and PHP February Issue" href="http://webandphp.com/issue-11" target="_blank">February issue</a>.</p>

<h4>Solr has quickly become one of the most popular search engines available. Due to Solr&#8217;s many features and its low barrier to entry it can be an ideal candidate when seeking a search engine. Solarium, a PHP Solr Client, takes Solr one step further by giving developers easier access to the Solr API.</h4>

<figure class='code'><figcaption><span>Listing 1 </span></figcaption>
 <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='json'><span class='line'><span class="p">{</span>
</span><span class='line'><span class="err"> </span> <span class="err"> </span> <span class="nt">&quot;require&quot;</span><span class="p">:</span> <span class="p">{</span>
</span><span class='line'><span class="err"> </span> <span class="err"> </span> <span class="err"> </span> <span class="err"> </span> <span class="nt">&quot;solarium/solarium&quot;</span><span class="p">:</span> <span class="s2">&quot;3.0.0&quot;</span>
</span><span class='line'><span class="err"> </span> <span class="err"> </span> <span class="p">}</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>




<figure class='code'><figcaption><span>Listing 2 </span></figcaption>
 <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
</pre></td><td class='code'><pre><code class='php'><span class='line'><span class="cp">&lt;?php</span>
</span><span class='line'><span class="nv">$config</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
</span><span class='line'><span class="err"> </span> <span class="err"> </span> <span class="s1">&#39;endpoint&#39;</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span>
</span><span class='line'><span class="err"> </span> <span class="err"> </span> <span class="err"> </span> <span class="err"> </span> <span class="s1">&#39;localhost&#39;</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span>
</span><span class='line'><span class="err"> </span> <span class="err"> </span> <span class="err"> </span> <span class="err"> </span> <span class="err"> </span> <span class="err"> </span> <span class="s1">&#39;host&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;127.0.0.1&#39;</span><span class="p">,</span> <span class="s1">&#39;port&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;8983&#39;</span><span class="p">,</span> <span class="s1">&#39;path&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;/solr/&#39;</span>
</span><span class='line'>        <span class="p">)</span>
</span><span class='line'>    <span class="p">)</span>
</span><span class='line'><span class="p">);</span>
</span><span class='line'>
</span><span class='line'><span class="c1">// new Solarium Client object</span>
</span><span class='line'><span class="nv">$client</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Solarium\Client</span><span class="p">(</span><span class="nv">$config</span><span class="p">);</span>
</span><span class='line'><span class="cp">?&gt;</span><span class="x"></span>
</span></code></pre></td></tr></table></div></figure>




<figure class='code'><figcaption><span>Listing 3 </span></figcaption>
 <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='xml'><span class='line'><span class="nt">&lt;field</span> <span class="na">name=</span><span class="s">&quot;id&quot;</span> <span class="na">type=</span><span class="s">&quot;int&quot;</span> <span class="na">indexed=</span><span class="s">&quot;true&quot;</span> <span class="na">stored=</span><span class="s">&quot;true&quot;</span> <span class="nt">/&gt;</span>
</span><span class='line'><span class="nt">&lt;field</span> <span class="na">name=</span><span class="s">&quot;name&quot;</span> <span class="na">type=</span><span class="s">&quot;string&quot;</span> <span class="na">indexed=</span><span class="s">&quot;true&quot;</span> <span class="na">stored=</span><span class="s">&quot;true&quot;</span> <span class="na">multiValued=</span><span class="s">&quot;true&quot;</span> <span class="nt">/&gt;</span>
</span><span class='line'><span class="nt">&lt;field</span> <span class="na">name=</span><span class="s">&quot;text&quot;</span> <span class="na">type=</span><span class="s">&quot;text&quot;</span> <span class="na">indexed=</span><span class="s">&quot;true&quot;</span> <span class="na">stored=</span><span class="s">&quot;true&quot;</span> <span class="nt">/&gt;</span>
</span></code></pre></td></tr></table></div></figure>


<p>Introduction to Solr: Search is an important part of most web projects and should be given much care. Throughout the years, making content searchable has changed a great deal. Obviously, exposing SQL queries to users through search is dangerous. Modern search implementations require a secure approach, such as a stand-alone search server, separate from site data. There are many search options to choose from. Your search list might include: Sphinx, Flax, ElasticSearch, Google, and Solr. Solr’s scalability, speed, built in features and community make it an ideal platform for any project. Luckily, integrating Solr into your PHP project has been made easy by the Solarium Project.</p>

<p>In Apache’s own words, “<em>Solr is an open source enterprise search server based on the Lucene Java search library, with XML/HTTP and JSON, Ruby, and Python APIs, hit highlighting, faceted search, caching, replication, and a web administration interface</em>” [1]. Apache Solr is an open source, extensible, stand-alone search engine, built on Lucene, managed by The Apache Software Foundation. There are currently two stable versions of Solr available for use; Solr 3.6.2 and Solr 4.0. Either version may be used with Solarium; Solr 4 ships with added features, however, so use Solr 4 if possible.</p>

<p>Solr is designed to run as a stand-alone Java web application (app). The documentation for downloading, installing, and running Solr can be found at <a href="http://lucene.apache.org/solr/tutorial.html" title="Solr Tutorial">http://lucene.apache.org/solr/tutorial.html</a>. Because Solr is meant to be separate from the primary project, it can be installed anywhere. All interactions with Solr happen over HTTP through a REST-like API. Solarium utilizes both PHP and JSON for its interactions with Solr.</p>

<p>One of the greatest features of Solr is its scalability. Replication can be set up to run multiple Solr instances in a master/slave setup, just like MySQL replication.The documentation for setting up a master/slave setup is very thorough, so it will not be discussed further here. Another option for scaling Solr is to search multiple search cores. Solr can run multiple search cores at a time. Solr can search multiple cores at a time through its distributed search and sharding capabilities. Large search indexes can be split into multiple smaller indexes; then through a distributed search multiple cores are searched. The best part of a multicore search setup is that not all cores need to exist on the same server. This allows for very flexible search architecture.</p>

<h3>Solarium acts as a bridge</h3>

<p>Solr has a REST-like API, so interactions with it are very simple and happen over HTTP. The Solarium Project is “<em>an open source Solr client library for PHP applications</em>” [2], which makes interacting with Solr even simpler. Solarium exists to expose the Solr API through an easy to use PHP library.</p>

<p>Installation of Solarium has been made very easy through the use of Composer (Listing 1). Installing through Composer will automatically add the library to the PHP autoload path. To install Solarium into a project not utilizing Composer, the files will need to be downloaded from GitHub (<a href="https://github.com/basdenooijer/solarium/tags" title="Solarium Library">https://github.com/basdenooijer/solarium/tags</a>). Next, add the solarium library to the PHP autoload path manually. After Solarium is installed, Solr can be accessed through sending a Solarium Client ($client) object to a configuration array. The configuration array should be made up of the Solr host, port and path (Listing 2).</p>

<h3>Adding content to Solr</h3>

<p>Before anything can be searched in Solr, documents (docs) must be added to the Solr index. Solr maintains a collection of docs in its index. A doc is a collection of fields and values. Solr fields must be defined in the Solr schema. A field can occur multiple times in a doc.</p>

<p>To make an update to Solr using Solarium, start with the <code>$client</code> object. Using the <code>$client</code> object, create an <code>$update</code> instance then make a doc:</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='php'><span class='line'><span class="x">$update = $client-&gt;createUpdate();</span>
</span><span class='line'><span class="x">$doc1 = $update-&gt;createDocument();</span>
</span></code></pre></td></tr></table></div></figure>


<p>With the newly created <code>$doc</code>, begin adding content to Solr fields as instances of the $doc:</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
</pre></td><td class='code'><pre><code class='php'><span class='line'><span class="x">$doc1-&gt;id = 123;</span>
</span><span class='line'><span class="x">$doc1-&gt;name = &#39;First Document&#39;;</span>
</span><span class='line'><span class="x">$doc1-&gt;text = &#39;This is the first document\&#39;s content&#39;;</span>
</span><span class='line'>
</span><span class='line'><span class="x">// Create another doc</span>
</span><span class='line'><span class="x">$doc2 = $update-&gt;createDocument();</span>
</span><span class='line'><span class="x">$doc2-&gt;id = 234;</span>
</span><span class='line'><span class="x">$doc2-&gt;name = &#39;Next Document&#39;;</span>
</span><span class='line'><span class="x">$doc2-&gt;text = &#39;This is the next document\&#39;s content&#39;;</span>
</span></code></pre></td></tr></table></div></figure>


<p>In this example, the Solr schema would have to be set up to accept the id, name and text fields. Solr ships with an example search app with a good demo of a Solr schema; each field will need to be added to the schema in order for Solr to add the docs to the search index (Listing 3). Next, add each <code>$doc</code> created to an array so that <code>addDocuments()</code> can be called on the array. This will run the Solr add command for every document in the array:</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='php'><span class='line'><span class="x">$update-&gt;addDocuments(array($doc1, $doc2));</span>
</span></code></pre></td></tr></table></div></figure>


<p>The newly-added docs will not actually become a permanent part of the Solr index until Solr is told to commit all added docs to its index. To do this with Solarium, call <code>addCommit()</code> to generate a commit message for Solr, then a call to <code>update()</code> with the <code>$update</code> will send the commit:</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='php'><span class='line'><span class="x">$update-&gt;addCommit(); $client-&gt;update($update);</span>
</span></code></pre></td></tr></table></div></figure>


<p>The new docs should now exist and be searchable using Solr.</p>

<h3>Searching Solr through Solarium</h3>

<p>Solarium offers a robust PHP API for searching Solr. To run a basic query, start with the $client object. Next, call the <code>createSelect()</code> instance of the <code>$client</code> object to generate the query for execution:</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='php'><span class='line'><span class="x">$query = $client=&gt;createSelect();</span>
</span><span class='line'>
</span><span class='line'><span class="x">// *:* is equivalent to telling solr to return all docs</span>
</span><span class='line'><span class="x">$query-&gt;setQuery(&#39;*:*&#39;);</span>
</span></code></pre></td></tr></table></div></figure>


<p>Because the <code>createSelect()</code> function is being used to generate the query, the <code>select()</code> function should be used when executing the query:</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='php'><span class='line'><span class="x">$resultSet = $client-&gt;select($query);</span>
</span></code></pre></td></tr></table></div></figure>


<p>Use the $resultSet array to iterate over the array and display the results:</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
</pre></td><td class='code'><pre><code class='php'><span class='line'><span class="x">echo &#39;&lt;div class=&quot;search-results&quot;&gt;&#39;;</span>
</span><span class='line'><span class="x">foreach ($resultSet as $result) {</span>
</span><span class='line'><span class="x">    echo &#39;&lt;div class=&quot;search-result&quot;&gt;&#39;;</span>
</span><span class='line'><span class="x">    echo &#39;&lt;p&gt;&#39; . $result-&gt;id . &#39;&lt;/p&gt;&#39;;</span>
</span><span class='line'><span class="x">    echo &#39;&lt;p&gt;&#39; . $result-&gt;name . &#39;&lt;/p&gt;&#39;;</span>
</span><span class='line'><span class="x">    echo &#39;&lt;p&gt;&#39; . $result-&gt;text . &#39;&lt;/p&gt;&#39;;</span>
</span><span class='line'><span class="x">    echo &#39;&lt;/div&gt;&#39;;</span>
</span><span class='line'><span class="x">}</span>
</span><span class='line'><span class="x">echo &#39;&lt;/div&gt;&#39;;</span>
</span></code></pre></td></tr></table></div></figure>


<p>The <code>$resultSet</code> can also be refined. Setting up pagination, for instance, is very easy:</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='php'><span class='line'><span class="x">$query-&gt;setStart(0)-&gt;setRows(10);</span>
</span></code></pre></td></tr></table></div></figure>


<p>Sorting is also very easy (note that Solr will sort by score if no sort is set):</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='php'><span class='line'><span class="x">$query-&gt;addSort(&#39;name&#39;, Select::SORT_ASC);</span>
</span></code></pre></td></tr></table></div></figure>


<p>Filtering, setting query fields, boosting, and faceting are also possible ways of searching Solr. Filtering is another way of narrowing search results without using a query. Query fields allow for control over what fields are searched. Boosting gives certain field’s higher precedence in the Search. Facets give users a way to better navigate search results. Solarium gives easy access to all the various ways of searching Solr content.</p>

<h3>Removing content from Solr</h3>

<p>Solr does not have a command called update; however, updates can be performed by re-adding content. Solr uses a unique identifier for each doc and only allows for one instance of the identifier in the search index. To update content, call the add command on an already existent Solr doc id. Sometimes updating Solr with new content isn’t enough. Sometimes the need to delete content from Solr arises. Doing this is similar to when adding docs, create an $update instance:</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='php'><span class='line'><span class="x">$update = $client-&gt;createUpdate();</span>
</span></code></pre></td></tr></table></div></figure>


<p>Using the $update instance, documents can be deleted by id or by query. This offers a great deal of flexibility for deleting content. Deleting by id is used more often because it offers very precise deletes:</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='php'><span class='line'><span class="x">$update-&gt;addDeleteById(234);</span>
</span><span class='line'><span class="x">$update-&gt;addCommit();</span>
</span><span class='line'><span class="x">$client-&gt;update($update);</span>
</span></code></pre></td></tr></table></div></figure>


<p>Deleting by query, however, can be incredibly powerful and useful. When starting development of a new search project with test content, for instance, deleting by query offers the ability to remove all test content. If all the test content starts with the word test, deleting the content is simple:</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='php'><span class='line'><span class="x">$update-&gt;addDeleteQuery(&#39;name:test*&#39;);</span>
</span><span class='line'><span class="x">$update-&gt;addCommit();</span>
</span><span class='line'><span class="x">$client-&gt;update($update);</span>
</span></code></pre></td></tr></table></div></figure>


<p>Another common practice is to wipe the index and start fresh. Using delete by query, this task is again made very simple:</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='php'><span class='line'><span class="x">$update-&gt;addDeleteQuery(&#39;*:*&#39;);</span>
</span><span class='line'><span class="x">$update-&gt;addCommit();</span>
</span><span class='line'><span class="x">$client-&gt;update($update);</span>
</span></code></pre></td></tr></table></div></figure>


<p>Solarium’s delete doc API is very useful in maintaining an up-to-date search index.</p>

<h3>Conclusion</h3>

<p>Solr is an incredibly scalable, powerful and easy-to-use search engine that should be considered for any search project. Solr is designed to be language agnostic through its REST-like API, and thanks to Solarium it fits very easily into any PHP project. This article covers only three use cases for Solarium; the examples shipped with Solarium offer a great deal more. Search highlighting, debugging, optimizing, and ‘more like this’ functionality are all possible with Solr and Solarium.</p>

<h4>References</h4>

<ol>
<li>Apache Solr: http://projects.apache.org/projects/solr.html</li>
<li>The Solarium Project: http://www.solarium-project.org/</li>
</ol>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Symfony2 Access Conrol]]></title>
    <link href="http://harmssite.com/2013/03/symfony2-access-conrol/" />
    <updated>2013-03-02T00:00:00-06:00</updated>
    <id>http://harmssite.com/2013/03/symfony2-access-conrol</id>
    <content type="html"><![CDATA[<p>I am very new to Symfony development. While developing a side project app I found I needed to control access to a certain area to logged in users only. Based on my previous development history I was expecting to have to determine if a user was logged in via the controller. I figured I would need to find an <code>is_logged_in</code> boolean and use it to determine user access control. What I found while doing my development is that Symfony2 takes care of access control in a much more eloquent way. Rather than having to determine if a user is logged in inside each controller, Symfony2 controls access using a system similar to its routing system. Inside a Symfony2 app there is, by default, a <code>security.yml</code> file that is used to control access. Inside the <code>security.yml</code> file locate the <code>access_control</code> declaration. By simply declaring a route inside the <code>access_control</code> yml array we can control which users have access to which routes, like so:</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class='yaml'><span class='line'><span class="l-Scalar-Plain">access_control</span><span class="p-Indicator">:</span>
</span><span class='line'>    <span class="p-Indicator">-</span> <span class="p-Indicator">{</span> <span class="nv">path</span><span class="p-Indicator">:</span> <span class="nv">^/login$</span><span class="p-Indicator">,</span> <span class="nv">role</span><span class="p-Indicator">:</span> <span class="nv">IS_AUTHENTICATED_ANONYMOUSLY</span> <span class="p-Indicator">}</span>
</span><span class='line'>    <span class="p-Indicator">-</span> <span class="p-Indicator">{</span> <span class="nv">path</span><span class="p-Indicator">:</span> <span class="nv">^/register</span><span class="p-Indicator">,</span> <span class="nv">role</span><span class="p-Indicator">:</span> <span class="nv">IS_AUTHENTICATED_ANONYMOUSLY</span> <span class="p-Indicator">}</span>
</span><span class='line'>    <span class="p-Indicator">-</span> <span class="p-Indicator">{</span> <span class="nv">path</span><span class="p-Indicator">:</span> <span class="nv">^/resetting</span><span class="p-Indicator">,</span> <span class="nv">role</span><span class="p-Indicator">:</span> <span class="nv">IS_AUTHENTICATED_ANONYMOUSLY</span> <span class="p-Indicator">}</span>
</span><span class='line'>    <span class="p-Indicator">-</span> <span class="p-Indicator">{</span> <span class="nv">path</span><span class="p-Indicator">:</span> <span class="nv">^/admin/</span><span class="p-Indicator">,</span> <span class="nv">role</span><span class="p-Indicator">:</span> <span class="nv">ROLE_ADMIN</span> <span class="p-Indicator">}</span>
</span><span class='line'>    <span class="p-Indicator">-</span> <span class="p-Indicator">{</span> <span class="nv">path</span><span class="p-Indicator">:</span> <span class="nv">^/new</span><span class="p-Indicator">,</span> <span class="nv">role</span><span class="p-Indicator">:</span> <span class="nv">ROLE_USER</span> <span class="p-Indicator">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>As you can see with my code, for anything beyond the <code>/admin/</code> route the <code>ROLE_ADMIN</code> is required. And for anyone accessing the <code>/new</code> route the <code>ROLE_USER</code> is required.</p>

<p>This is obviously pretty trivial stuff, but for somebody new to Symfony2 development like myself, I found it an incredibly simple and powerful way of controlling access to my app.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[eZ Publish 5 - First Thoughts]]></title>
    <link href="http://harmssite.com/2013/01/ez-publish-5-first-thoughts/" />
    <updated>2013-01-19T00:00:00-06:00</updated>
    <id>http://harmssite.com/2013/01/ez-publish-5-first-thoughts</id>
    <content type="html"><![CDATA[<div class="pull-right"><img class="" alt="Syfomy Logo" title="Symfony Logo" src="https://s3.amazonaws.com/hs_blog_content/images/symfony-logo.png" width="206" height="205" /></div>


<p>I finally decided on my first eZ Publish 5 project&#8230; my site of course. I am currently in the middle of upgrading my wordpress install to eZ Publish. Honestly, I don&#8217;t really need anything more than a simple Wordpress install, but it will be nice to get an eZ5 site under my belt.</p>

<p>Seeing as I am in the middle of development, there have been a few bumps in the development road that I have found and would like to share. Firstly, I can find no way to run eZ Publish 5 completely in legacy mode, no matter what I do my pagelayout template needs to be a twig template. I posed the question to the eZ Community and it sounds like this should be possible, but it just wouldn&#8217;t work for me (see the discussion <a href="http://bit.ly/WhVHwu" title="Overriding templates in eZ 5">here</a>). I actually don&#8217;t have a problem with this, it&#8217;s not like being forced to use Symfony is a bad thing.</p>

<p>Second, I do not see a strait-forward way to run multiple sites in one eZ Publish 5 install right now. Site settings are declared in the <code>ezpublish.yml</code> file and are grouped appropriately. My problem is that the <code>parameters.yml</code> file only allows for the declaration of one default template. In my opinion the default template declaration should be tied to a siteaccess or a siteaccess group.</p>

<p>Third, the <code>index_dev.php</code> file doesn&#8217;t work for some reason. It would be nice to be able to use the Symfony dev toolbar. So far my only workaround has been to add the dev params to the index.php file. Either fixing this or allowing <code>DebugOutput</code> on a Symfony generated page would suffice.</p>

<p>It wouldn&#8217;t be fair to simply criticize eZ5, because it does work. The eZ Team did a hell of a job with eZ5, far more than I would have expected for a first iteration. Honestly I was expecting eZ5 to switch to the Symfony Components for round 1 and work on the rest later.</p>

<p>I think that far and above any other nicety of eZ5 is the ability to generate custom routes. Creating a custom module in eZ 4 was not exactly easy, but now with Symfony, creating a custom route/controller/view is extremely straight-forward and borderline easy. If a person has ever worked with Symfony in the past, creating custom &#8216;modules&#8217; will be a snap.</p>

<p>Another awesome part of eZ5 is the full REST API. Although I have yet to use it, I know it is there and that the eZ Team put a lot of work into it, so I have to give it props.</p>

<p>Finally, twig is awesome to work with.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Optimizing Solr To Fit Your Needs Part 2]]></title>
    <link href="http://harmssite.com/2012/12/optimizing-solr-to-fit-your-needs-part-2/" />
    <updated>2012-12-07T00:00:00-06:00</updated>
    <id>http://harmssite.com/2012/12/optimizing-solr-to-fit-your-needs-part-2</id>
    <content type="html"><![CDATA[<p>I am finally taking the time to write about optimizing the Solr schema file. In my last post I showed that eZ Find already ships with a default search field called <code>ezf_df_text</code>. The downside of searching one field is that field needs to be controlled, and the only way it can be controlled is by manually editing the Solr schema file. As you might expect, eZ Find does not control this file very well out of the box.</p>

<figure class='code'><figcaption><span>schema.xml </span></figcaption>
 <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='xml'><span class='line'><span class="nt">&lt;copyField</span> <span class="na">source=</span><span class="s">&quot;*_lk&quot;</span> <span class="na">dest=</span><span class="s">&quot;ezf_df_text&quot;</span><span class="nt">/&gt;</span>
</span><span class='line'><span class="nt">&lt;copyField</span> <span class="na">source=</span><span class="s">&quot;*_k&quot;</span> <span class="na">dest=</span><span class="s">&quot;ezf_df_text&quot;</span><span class="nt">/&gt;</span>
</span><span class='line'><span class="nt">&lt;copyField</span> <span class="na">source=</span><span class="s">&quot;*_t&quot;</span> <span class="na">dest=</span><span class="s">&quot;ezf_df_text&quot;</span><span class="nt">/&gt;</span>
</span><span class='line'><span class="nt">&lt;copyField</span> <span class="na">source=</span><span class="s">&quot;*_s&quot;</span> <span class="na">dest=</span><span class="s">&quot;ezf_df_text&quot;</span><span class="nt">/&gt;</span>
</span></code></pre></td></tr></table></div></figure>


<p>A copyField will take any field you tell it to and <em>copy it</em> into another field. The code above is what ships with eZ Find, every single <code>*_lk</code> (lckeyword), <code>*_k</code> (keyword), <code>*_t</code> (text), and <code>*_s</code> (string) is added to the <code>ezf_df_text</code> field. For obvious reasons the average installation probably doesn&#8217;t need every piece of content searchable. The first step is to <strong>delete the default copyFields</strong> (e.g. your site users probably shouldn&#8217;t be searched by default).</p>

<!--more-->


<p>Luckily, there is only one other step! Unfortunately, this one step can be very time consuming. Visit the <code>luke</code> output for your Solr install and make a list of all the fields you need to search. Make a copyField for every field you want to search, adding each field to the <code>ezf_df_text</code> field.</p>

<p>Remember, this can offer major speed improvements in your searches, especially if you are managing a large amount of content. There are still other optimizations (stored/not stored, indexed/not indexed, term vectors, etc), but that is for another time.</p>

<p>Finally, I did submit a pull request to the eZ Find project. It adds a new search parameter allowing users to declare custom search fields.
<a href="http://bit.ly/Vp98IU">https://github.com/ezsystems/ezfind/pull/93</a></p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Learning Symfony]]></title>
    <link href="http://harmssite.com/2012/11/learning-symfony/" />
    <updated>2012-11-21T00:00:00-06:00</updated>
    <id>http://harmssite.com/2012/11/learning-symfony</id>
    <content type="html"><![CDATA[<div class="pull-right"><img title="Nashville Symfony" src="https://s3.amazonaws.com/hs_blog_content/images/symfony2.jpg" alt="Nashville Symfony" width="240" height="180" /></div>


<p> I have spent a good deal of my freetime this past month or two learning as much about about the php framework Symfony as possible. The moment that eZ Systems announced that they were adopting the Symfony framework I knew that I would be be spending some time with it. I have found that Symfony doesn&#8217;t have the lowest barrier to entry so it has been a process, to say the least. I have a blog that has helped matters a great deal and so I wanted to give it some props here. If you are like me, wanting to learn Symfony but lacking time and resources, you should really check this site out: <a href="http://tutorial.symblog.co.uk/" title="Symblog: Creating a Blog in Symfony2">Symblog: Creating a Blog in Symfony2</a></p>

<p>The blog starts with the basics and explores a good deal of Symfony components in detail. In the end you will be left with a barley usable blog, but that is alright, it leaves you with a project to fix. It is a tutorial for Symfony 2.0, and because Symfony is currently on 2.1.3 you will notice some part don&#8217;t work the way you expect (but I think that forces you to learn more anyway). The tutorial also doesn&#8217;t use Composer at all; so remember, when the blog tells you to install something, use Composer and skip over the way they tell you how to do it. I hope you enjoy the tutorial, I know I did (I have not currently completed the tutorial but am nearing completion at the time of this writing).</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Skype version 6]]></title>
    <link href="http://harmssite.com/2012/11/skype-version-6/" />
    <updated>2012-11-01T00:00:00-05:00</updated>
    <id>http://harmssite.com/2012/11/skype-version-6</id>
    <content type="html"><![CDATA[<div class="pull-right"><img title="MessageViewVersion" src="https://s3.amazonaws.com/hs_blog_content/images/skype-screenshot.png" alt="Message View Version" width="352" height="229" /></div>


<p>I recently updated to Skype 6 and found something interesting out. My style package that worked in Skype 5 would not work in Skype 6. With some digging, we found out that in order to make your Skype 5 style work in Skype 6 you need to update the <code>MessageViewVersion</code> to version 7 (I have no idea why). So, with that, have fun updating your Skype to the latest version while still getting use out of your favorite Skype theme.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[American Politics]]></title>
    <link href="http://harmssite.com/2012/10/american-politics/" />
    <updated>2012-10-03T00:00:00-05:00</updated>
    <id>http://harmssite.com/2012/10/american-politics</id>
    <content type="html"><![CDATA[<p>I try as hard as I can to stay out of politics. I have my opinions like everybody else and I try to not start arguments as often as possible because I also value my friends and family. But with the American presidential election around the corner, I just had to share this bit of gold.</p>

<div class='embed tweet'><blockquote class="twitter-tweet"><p>Michele Bachman is on the U.S. Intelligence Committee, and Todd Akin on the Science Committee. Let that sink in for a minute.</p>&mdash; Jorge Villalobos (@minusfive) <a href="https://twitter.com/minusfive/status/253246165108277248">October 2, 2012</a></blockquote>
<script async src="http://harmssite.com//platform.twitter.com/widgets.js" charset="utf-8"></script></div>


<ul>
<li><a href="http://articles.cnn.com/2012-07-30/opinion/opinion_tarin-bachmann-muslims_1_witch-hunt-michele-bachmann-muslim-brotherhood" title="Michele Bachmann and Muslim witch hunts">Michele Bachmann and Muslim witch hunts</a></li>
<li><a href="http://gawker.com/5936050/republican-senate-nominee-explains-that-women-dont-really-get-pregnant-from-legitimate-rape" title="Republican Senate Nominee Explains That Women Don’t Really Get Pregnant From ‘Legitimate Rape’">Republican Senate Nominee Explains That Women Don’t Really Get Pregnant From ‘Legitimate Rape’</a></li>
</ul>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[AWS authorize security groups across acounts « ShellRunner]]></title>
    <link href="http://harmssite.com/2012/09/aws-authorize-security-groups-across-acounts-shellrunner/" />
    <updated>2012-09-28T00:00:00-05:00</updated>
    <id>http://harmssite.com/2012/09/aws-authorize-security-groups-across-acounts-shellrunner</id>
    <content type="html"><![CDATA[<p>Just had to share this post since I helped a little bit with it. Very handy little tip about authorizing security groups across AWS accounts.</p>

<p><a href="http://shellrunner.com/2012/09/28/aws-authorize-security-groups-across-acounts/" title="AWS authorize security groups across acounts « ShellRunner">AWS authorize security groups across acounts « ShellRunner</a>.</p>

<p>It is a post by <a title="Jackson Murtha on Twitter" href="https://twitter.com/jacksonmurtha" target="_blank">@jacksonmurtha</a> so we can trust that it is good.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Solr Query for Mimicking SQL IN Operator Functionality]]></title>
    <link href="http://harmssite.com/2012/09/solr-query-for-mimicking-sql-in-operator-functionality/" />
    <updated>2012-09-13T00:00:00-05:00</updated>
    <id>http://harmssite.com/2012/09/solr-query-for-mimicking-sql-in-operator-functionality</id>
    <content type="html"><![CDATA[<div class="pull-right"><img title="Learning SQL" src="https://s3.amazonaws.com/hs_blog_content/images/select-query.jpg" alt="Learning SQL" width="240" height="180" /></div>


<p>I did a lot of playing around with solr to get this right. Unfortunately there is not a lot of documentation on searching within a certain field. With the SQL language you can search for multiple terms in a given field using the <code>IN</code> operator. In Solr you have the option of specifying a field using the <code>qf</code> operator, but what if you have more search terms searching other fields? The problem becomes far more complex. Given the following SQL statement how would we query Solr?</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='mysql'><span class='line'><span class="k">SELECT</span> <span class="o">*</span>
</span><span class='line'><span class="k">FROM</span> <span class="n">table_name</span>
</span><span class='line'><span class="k">WHERE</span> <span class="n">column_name</span> <span class="k">IN</span> <span class="p">(</span><span class="n">value1</span><span class="p">,</span><span class="n">value2</span><span class="p">,...)</span> <span class="k">AND</span> <span class="n">other_column</span><span class="o">=</span><span class="s1">&#39;foo&#39;</span>
</span></code></pre></td></tr></table></div></figure>


<p>There are couple of ways to do this, but I think there is one very good and much easier way. The first obvious way to query solr is to match the fields to columns manually.</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='http'><span class='line'><span class="err">/select?q=*:*&amp;fq=column_name:value1 AND column_name:value2 AND other_colum:&#39;foo&#39;</span>
</span></code></pre></td></tr></table></div></figure>


<p>This is all fine and dandy but what if I want to be able to add a list of content to the query? Adding the column name every time can become a chore and make the query unnecessarily large. To do an <code>IN</code> query try this:</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='http'><span class='line'><span class="err">/select?q=*:*&amp;fq=column_name:+(value1 value2) AND other_colum:&#39;foo&#39;</span>
</span></code></pre></td></tr></table></div></figure>


<p>Having used this one before, I can tell you it works for me using Solr 3.6 and that the placement of the + symbol is key.</p>

<p>And what about a <code>NOT IN</code> query?</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='mysql'><span class='line'><span class="k">SELECT</span> <span class="o">*</span>
</span><span class='line'><span class="k">FROM</span> <span class="n">table_name</span>
</span><span class='line'><span class="k">WHERE</span> <span class="n">column_name</span> <span class="k">NOT</span> <span class="k">IN</span> <span class="p">(</span><span class="n">value1</span><span class="p">,</span><span class="n">value2</span><span class="p">,...)</span> <span class="k">AND</span> <span class="n">other_column</span><span class="o">=</span><span class="s1">&#39;foo&#39;</span>
</span></code></pre></td></tr></table></div></figure>


<p>The &#8216;bad&#8217; way:</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='http'><span class='line'><span class="err">/select?q=*:*&amp;fq=-column_namevalue1 AND -column_name:value2 AND other_colum:&#39;foo&#39;</span>
</span></code></pre></td></tr></table></div></figure>


<p>This one I found from working with eZ Publish and eZ Find, and I happen to like it a lot. It is a clever little Solr query that selects all from the column then filters out what we don&#8217;t want.</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='http'><span class='line'><span class="err">/select?q=*:*&amp;fq=other_colum:&#39;foo&#39; AND column_name:[* TO *] -column_name:(value1 value2)</span>
</span></code></pre></td></tr></table></div></figure>


<p><code>column_name:[* TO *]</code> is like saying select all from the column, but then we add <code>-column_name:(value1 value2)</code> to filter out what we don&#8217;t want.</p>

<p>Cheers and good luck!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Optimizing Solr to fit your needs Part 1]]></title>
    <link href="http://harmssite.com/2012/08/optimizing-solr-to-fit-your-needs-part-1/" />
    <updated>2012-08-25T00:00:00-05:00</updated>
    <id>http://harmssite.com/2012/08/optimizing-solr-to-fit-your-needs-part-1</id>
    <content type="html"><![CDATA[<div class="pull-right"><img class="zemanta-img-inserted zemanta-img-configured" title="Solr logo" src="https://s3.amazonaws.com/hs_blog_content/images/Solr-logo.png" alt="Solr logo" width="283" height="156" /></div>


<p>Let me start by saying that eZ Find is a fantastic implementation of <a class="zem_slink" title="Apache Solr" href="http://lucene.apache.org/solr/" rel="homepage" target="_blank">Solr</a> functionality. With eZ Find you get a fantastic search, out of the box. eZ Find gathers all the content in your system and organizes it for you into strings, text, and keywords (there are more but those the types I use most often). It can look at an <a class="zem_slink" title="EZ Publish" href="http://ez.no/" rel="homepage" target="_blank">eZ Publish</a> keyword and know that it should thereby be a Solr keyword, again, all out of the box. There are however some serious limitations when it comes time to customize it to meet your system&#8217;s needs. Do not underestimate the power found in customizing Solr to meet your website&#8217;s needs. The default setup is great, it&#8217;s made to fit into any system with very little effort; but, just because it&#8217;s made to fit in any system does not mean that it should be used for every system.</p>

<p>One of the best things we could have ever done for a large Solr install was to customize a default search field. You might say, &#8220;But eZ Find already creates a default search field for you.&#8221; And you&#8217;d be right.</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='xml'><span class='line'><span class="c">&lt;!-- field for the QueryParser to use when an explicit fieldname is absent --&gt;</span>
</span><span class='line'><span class="nt">&lt;defaultSearchField&gt;</span>ezf_df_text<span class="nt">&lt;/defaultSearchField&gt;</span>
</span></code></pre></td></tr></table></div></figure>


<p>The thing that the default search field in eZ Find does not do, however, is get used. There is no way in eZ Find to tell it to search just one field (at least as far as I know). I did some testing in our environment, these numbers will change from system to system, but in our&#8217;s each search took almost 10 times as long to search all fields individually vs searching just 1 field. We gave eZ Find the option to search one given field, if defined, and it vastly improved our search experience.</p>

<p>eZ Find by default looks at all &#8216;searchable&#8217; fields and adds them to either the <a title="qf" href="http://wiki.apache.org/solr/DisMaxQParserPlugin#qf_.28Query_Fields.29"><code>qf</code></a> (if you are using the dismax search like you should be) or it searches every searchable field individually (<code>attr_title_t:(*:*)</code>, <code>attr_title_s:(*:*)</code>, etc, etc, for all searchable fields). All the &#8216;searchable&#8217; fields are by default added to the <code>ezf_df_text</code> field, so you should really do yourself a favor and search just one field, it is a noticable speed improvement, especially in large systems.</p>

<p>In Part 2 I will talk about how to better optimize the Solr <code>schema.xml</code> file using the <code>ezf_df_text</code> field.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Multiple .gitignore files versus .gitkeep files]]></title>
    <link href="http://harmssite.com/2012/08/gitignore-vs-gitkeep/" />
    <updated>2012-08-18T00:00:00-05:00</updated>
    <id>http://harmssite.com/2012/08/gitignore-vs-gitkeep</id>
    <content type="html"><![CDATA[<div class="pull-right"><img src="https://s3.amazonaws.com/hs_blog_content/images/Git_icon.png" alt="Git" title="Git" width="256" height="256" /></div>


<p>I have been a devout git user for as long as I have been programming. I was lucky enough to bypass subversion entirely, at least that is what my friends who used svn have told me.</p>

<p>The cool thing about git is that it tracks changes, not files or directories. When I create a new empty directory that directory is not tracked by git because it has no file changes inside, hence, the directory will never make it into git until I add a file to that directory. For this example I am going to use the logs directory of a virtual site. In my logs directory I have two files, an <code>error_log</code> and an <code>access_log</code>. Apache error logs and access logs should never be tracked by version control because they are logs that are specific to the given system the site is installed on. However, we should try to track the logs directory in version control. As hinted at before, we can do this in one of two ways.</p>

<!--more-->


<p>First, the <code>.gitignore</code> file. We can add as my <code>.gitignore</code> files as we need. You can place these files in any directory you want tracked that wouldn&#8217;t be already (technically you can put them anywhere you want and have as many as you want, but don&#8217;t go excessive). <code>.gitignore</code> files are technically the preferred way to go about tracking empty directories because these files are actually read by git. The <code>.gitignore</code> file structure is pretty simple, for defining how to ignore the contents of the logs file you just need to tell git the relative path (relative to the path of the <code>.gitignore</code> file).
<code>.gitignore</code> file:</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="c"># log files</span>
</span><span class='line'>logs/access_log
</span><span class='line'>logs/error_log
</span></code></pre></td></tr></table></div></figure>


<p>How to track the empty directory with <code>.gitignore</code></p>

<div class="pull-right"><img class="alignnone size-full wp-image-202" title="gitignore" src="https://s3.amazonaws.com/hs_blog_content/images/gitignore.png" alt="gitignore" width="264" height="130" /></div>


<p>So, as you can see this is pretty simple, but I think that multiple <code>.gitignore</code> files can become confusing.</p>

<p>Second, the <code>.gitkeep</code> file. This is a git hack that was first adopted by the Rails community. <code>.gitkeep</code> files are not an official file recognized by git. That said, because they start with a <code>'.'</code> they will be a hidden file in any system as well as have it&#8217;s changes tracked by git. Technically our file name could be <code>.foobar</code> and it would still work. The reason I like the <code>.gitkeep</code> files is because it&#8217;s purpose is directly implied by the name of the file (keep the directory in git even if it&#8217;s directory is empty). Another reason I like the use of <code>.gitkeep</code> files over <code>.gitignore</code> is I like to keep all ignored files in one spot, it can be hard to track what is ignored if there are multiple <code>.gitignore</code> files at work in a system.
The <code>.gitkeep</code> file at work:</p>

<div class="pull-right"><img src="https://s3.amazonaws.com/hs_blog_content/images/gitkeep.png" alt="" title="gitkeep" width="283" height="132" class="alignnone size-full wp-image-206" /></div>


<p>Pretty simple right? So, I have my preference, what is yours?</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[EZ Publish with Sublime]]></title>
    <link href="http://harmssite.com/2012/06/ez-publish-with-sublime/" />
    <updated>2012-06-30T00:00:00-05:00</updated>
    <id>http://harmssite.com/2012/06/ez-publish-with-sublime</id>
    <content type="html"><![CDATA[<div class="pull-right"><img title="Sublime Text icon" src="https://s3.amazonaws.com/hs_blog_content/images/sublime_text_icon_2181-150x150.png" alt="Sublime Text icon" width="150" height="150" /></div>


<p>A while back I fell in love with <a title="Sublime Text 2" href="http://bit.ly/MHuK34" target="_blank">Sublime Text 2</a> and its&#8217; many advantages over TextMate. What it lacked however was any real support for the eZ Publish templating language (no different than TextMate). What I wanted was a simple editor that offered variable and method highlighting equivalent to a nice IDE like PHPStorm. I was originally using the Smarty package for TextMate (you can use any TextMate package in Sublime), but that does not offer a lot of method highlighting support for eZ. So what I decided to do was use the Smarty package as a template for adding more language support for eZ Publish. What I have is far from complete; I usually only add to it when I use a method that is not already supported. You can find it out on <a title="ez sublime on GitHub" href="http://bit.ly/N4eTcp" target="_blank">GitHub</a>. It is my hope that there are some eZ Publish devs out there that really enjoy Sublime as I do and want to help me grow the package. Remember, it is far from complete, but nonetheless, I really hope that you enjoy the language highlighting, and if you do feel free to contribute.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Fixing Shards in eZ Find]]></title>
    <link href="http://harmssite.com/2012/06/fixing-shards-in-ez-find/" />
    <updated>2012-06-29T00:00:00-05:00</updated>
    <id>http://harmssite.com/2012/06/fixing-shards-in-ez-find</id>
    <content type="html"><![CDATA[<p>I am way overdue on my promise to show you how to make shards work. As I said before, shards in eZ Find do not work out of the box. In the code the <code>$shardQuery</code> is built properly but the variable is never actually used after it is created. What I did to make this work is a simple if/else block inside the <code>$queryHandler</code> switch. I am not submitting this as a pull request to eZ Find at the moment just because I do not like the way I made this work, I feel like there is a better way to do it. Nevertheless here is my code to make Shards work, I hope you enjoy and moreover I hope you suggest a better way to make the code work ;)</p>

<!--more-->




<figure class='code'><figcaption><span>ezfezpsolrquerybuilder.php </span></figcaption>
 <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
<span class='line-number'>33</span>
<span class='line-number'>34</span>
<span class='line-number'>35</span>
<span class='line-number'>36</span>
<span class='line-number'>37</span>
<span class='line-number'>38</span>
<span class='line-number'>39</span>
<span class='line-number'>40</span>
<span class='line-number'>41</span>
<span class='line-number'>42</span>
<span class='line-number'>43</span>
<span class='line-number'>44</span>
<span class='line-number'>45</span>
<span class='line-number'>46</span>
<span class='line-number'>47</span>
<span class='line-number'>48</span>
<span class='line-number'>49</span>
<span class='line-number'>50</span>
<span class='line-number'>51</span>
<span class='line-number'>52</span>
<span class='line-number'>53</span>
<span class='line-number'>54</span>
<span class='line-number'>55</span>
<span class='line-number'>56</span>
<span class='line-number'>57</span>
<span class='line-number'>58</span>
<span class='line-number'>59</span>
<span class='line-number'>60</span>
<span class='line-number'>61</span>
<span class='line-number'>62</span>
<span class='line-number'>63</span>
<span class='line-number'>64</span>
<span class='line-number'>65</span>
<span class='line-number'>66</span>
</pre></td><td class='code'><pre><code class='php'><span class='line'><span class="cp">&lt;?php</span>
</span><span class='line'><span class="k">switch</span> <span class="p">(</span> <span class="nv">$queryHandler</span> <span class="p">)</span>
</span><span class='line'><span class="p">{</span>
</span><span class='line'>    <span class="k">case</span> <span class="s1">&#39;standard&#39;</span><span class="o">:</span>
</span><span class='line'>        <span class="c1">// @todo: this is more complicated</span>
</span><span class='line'>        <span class="c1">// build the query against all &quot;text&quot; like fields</span>
</span><span class='line'>        <span class="c1">// should take into account all the filter fields and class filters to shorten the query</span>
</span><span class='line'>        <span class="c1">// need to build: Solr q</span>
</span><span class='line'>        <span class="k">if</span> <span class="p">(</span> <span class="nb">array_key_exists</span><span class="p">(</span> <span class="s1">&#39;fields&#39;</span><span class="p">,</span> <span class="nv">$boostFunctions</span> <span class="p">)</span> <span class="p">)</span>
</span><span class='line'>        <span class="p">{</span>
</span><span class='line'>            <span class="k">if</span> <span class="p">(</span><span class="k">false</span> <span class="o">!=</span> <span class="nv">$shardQuery</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>            <span class="nv">$handlerParameters</span> <span class="o">=</span> <span class="k">array</span> <span class="p">(</span> <span class="s1">&#39;q&#39;</span> <span class="o">=&gt;</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">buildMultiFieldQuery</span><span class="p">(</span> <span class="nv">$searchText</span><span class="p">,</span> <span class="nb">array_merge</span><span class="p">(</span> <span class="nv">$queryFields</span><span class="p">,</span> <span class="nv">$extraFieldsToSearch</span> <span class="p">),</span> <span class="nv">$boostFunctions</span><span class="p">[</span><span class="s1">&#39;fields&#39;</span><span class="p">]</span> <span class="p">),</span>
</span><span class='line'>                                     <span class="s1">&#39;qt&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;standard&#39;</span><span class="p">,</span>
</span><span class='line'>                                     <span class="s1">&#39;shards&#39;</span> <span class="o">=&gt;</span> <span class="nv">$shardQuery</span><span class="p">);</span>
</span><span class='line'>            <span class="p">}</span>
</span><span class='line'>            <span class="k">else</span> <span class="p">{</span>
</span><span class='line'>            <span class="nv">$handlerParameters</span> <span class="o">=</span> <span class="k">array</span> <span class="p">(</span> <span class="s1">&#39;q&#39;</span> <span class="o">=&gt;</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">buildMultiFieldQuery</span><span class="p">(</span> <span class="nv">$searchText</span><span class="p">,</span> <span class="nb">array_merge</span><span class="p">(</span> <span class="nv">$queryFields</span><span class="p">,</span> <span class="nv">$extraFieldsToSearch</span> <span class="p">),</span> <span class="nv">$boostFunctions</span><span class="p">[</span><span class="s1">&#39;fields&#39;</span><span class="p">]</span> <span class="p">),</span>
</span><span class='line'>                                     <span class="s1">&#39;qt&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;standard&#39;</span><span class="p">,</span> <span class="p">);</span>
</span><span class='line'>            <span class="p">}</span>
</span><span class='line'>
</span><span class='line'>        <span class="p">}</span>
</span><span class='line'>        <span class="k">else</span>
</span><span class='line'>        <span class="p">{</span>
</span><span class='line'>            <span class="k">if</span> <span class="p">(</span><span class="k">false</span> <span class="o">!=</span> <span class="nv">$shardQuery</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>            <span class="nv">$handlerParameters</span> <span class="o">=</span> <span class="k">array</span> <span class="p">(</span> <span class="s1">&#39;q&#39;</span> <span class="o">=&gt;</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">buildMultiFieldQuery</span><span class="p">(</span> <span class="nv">$searchText</span><span class="p">,</span> <span class="nb">array_merge</span><span class="p">(</span> <span class="nv">$queryFields</span><span class="p">,</span> <span class="nv">$extraFieldsToSearch</span> <span class="p">)</span> <span class="p">),</span>
</span><span class='line'>                                     <span class="s1">&#39;qt&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;standard&#39;</span><span class="p">,</span>
</span><span class='line'>                                     <span class="s1">&#39;shards&#39;</span> <span class="o">=&gt;</span> <span class="nv">$shardQuery</span><span class="p">);</span>
</span><span class='line'>            <span class="p">}</span>
</span><span class='line'>            <span class="k">else</span><span class="p">{</span>
</span><span class='line'>                <span class="nv">$handlerParameters</span> <span class="o">=</span> <span class="k">array</span> <span class="p">(</span> <span class="s1">&#39;q&#39;</span> <span class="o">=&gt;</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">buildMultiFieldQuery</span><span class="p">(</span> <span class="nv">$searchText</span><span class="p">,</span> <span class="nb">array_merge</span><span class="p">(</span> <span class="nv">$queryFields</span><span class="p">,</span> <span class="nv">$extraFieldsToSearch</span> <span class="p">)</span> <span class="p">),</span>
</span><span class='line'>                                     <span class="s1">&#39;qt&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;standard&#39;</span> <span class="p">);</span>
</span><span class='line'>            <span class="p">}</span>
</span><span class='line'>        <span class="p">}</span>
</span><span class='line'>        <span class="k">break</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'>    <span class="k">case</span> <span class="s1">&#39;simplestandard&#39;</span><span class="o">:</span>
</span><span class='line'>        <span class="c1">// not to do much, searching is against the default aggregated field</span>
</span><span class='line'>        <span class="c1">// only highlightfields</span>
</span><span class='line'>        <span class="nv">$highLightFields</span> <span class="o">=</span> <span class="k">array</span> <span class="p">(</span> <span class="s1">&#39;ezf_df_text&#39;</span> <span class="p">);</span>
</span><span class='line'>        <span class="nv">$handlerParameters</span> <span class="o">=</span> <span class="k">array</span> <span class="p">(</span> <span class="s1">&#39;q&#39;</span> <span class="o">=&gt;</span> <span class="nv">$searchText</span><span class="p">,</span>
</span><span class='line'>                                     <span class="s1">&#39;qt&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;standard&#39;</span><span class="p">,</span>
</span><span class='line'>                                     <span class="s1">&#39;hl.usePhraseHighlighter&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;true&#39;</span><span class="p">,</span>
</span><span class='line'>                                     <span class="s1">&#39;hl.highlightMultiTerm&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;true&#39;</span> <span class="p">);</span>
</span><span class='line'>        <span class="k">break</span><span class="p">;</span>
</span><span class='line'>    <span class="k">case</span> <span class="s1">&#39;ezpublish&#39;</span><span class="o">:</span>
</span><span class='line'>        <span class="c1">// the dismax based handler, just keywordss input, most useful for ordinary queries by users</span>
</span><span class='line'>        <span class="c1">// need to build: Solr q, qf, dismax specific parameters</span>
</span><span class='line'>
</span><span class='line'>    <span class="k">default</span><span class="o">:</span>
</span><span class='line'>        <span class="c1">// ezpublish of course, this to not break BC and is the most &quot;general&quot;</span>
</span><span class='line'>        <span class="c1">// if another value is specified, it is supposed to be a dismax like handler</span>
</span><span class='line'>        <span class="c1">// with possible other tuning variables then the stock provided &#39;ezpublish&#39; in solrconfi.xml</span>
</span><span class='line'>        <span class="c1">// remark it should be lowercase in solrconfig.xml!</span>
</span><span class='line'>        <span class="k">if</span> <span class="p">(</span><span class="k">false</span> <span class="o">!=</span> <span class="nv">$shardQuery</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>            <span class="nv">$handlerParameters</span> <span class="o">=</span> <span class="k">array</span> <span class="p">(</span> <span class="s1">&#39;q&#39;</span> <span class="o">=&gt;</span> <span class="nv">$searchText</span><span class="p">,</span>
</span><span class='line'>                                         <span class="s1">&#39;qf&#39;</span> <span class="o">=&gt;</span> <span class="nb">implode</span><span class="p">(</span> <span class="s1">&#39; &#39;</span><span class="p">,</span> <span class="nb">array_merge</span><span class="p">(</span> <span class="nv">$queryFields</span><span class="p">,</span> <span class="nv">$extraFieldsToSearch</span> <span class="p">)</span> <span class="p">),</span>
</span><span class='line'>                                         <span class="s1">&#39;qt&#39;</span> <span class="o">=&gt;</span> <span class="nv">$queryHandler</span><span class="p">,</span>
</span><span class='line'>                                         <span class="s1">&#39;shards&#39;</span> <span class="o">=&gt;</span> <span class="nv">$shardQuery</span> <span class="p">);</span>
</span><span class='line'>        <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
</span><span class='line'>            <span class="nv">$handlerParameters</span> <span class="o">=</span> <span class="k">array</span> <span class="p">(</span> <span class="s1">&#39;q&#39;</span> <span class="o">=&gt;</span> <span class="nv">$searchText</span><span class="p">,</span>
</span><span class='line'>                                         <span class="s1">&#39;qf&#39;</span> <span class="o">=&gt;</span> <span class="nb">implode</span><span class="p">(</span> <span class="s1">&#39; &#39;</span><span class="p">,</span> <span class="nb">array_merge</span><span class="p">(</span> <span class="nv">$queryFields</span><span class="p">,</span> <span class="nv">$extraFieldsToSearch</span> <span class="p">)</span> <span class="p">),</span>
</span><span class='line'>                                         <span class="s1">&#39;qt&#39;</span> <span class="o">=&gt;</span> <span class="nv">$queryHandler</span> <span class="p">);</span>
</span><span class='line'>
</span><span class='line'>        <span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>



]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Solr 3.6 Update]]></title>
    <link href="http://harmssite.com/2012/05/solr-3-6-update/" />
    <updated>2012-05-14T00:00:00-05:00</updated>
    <id>http://harmssite.com/2012/05/solr-3-6-update</id>
    <content type="html"><![CDATA[<p>Turns out that when using shards to search multiple cores (shards in general actually) binary is not returned properly. I found an update to the trunk (4.x) version of Solr and was successfully able to update my version of Solr 3.6. I am submitting a pull request of the code update to Solr as well a new war file to eZ Find, but in the meantime you can download the solr.war file on GitHub (it is in <a href="https://github.com/harmstyler/ezfind" title="harmstyler eZ Find fork">my eZ Find branch</a>). Enjoy!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Searching Multiple Solr Cores using Shards and eZ Find]]></title>
    <link href="http://harmssite.com/2012/05/ezfind-shards/" />
    <updated>2012-05-08T00:00:00-05:00</updated>
    <id>http://harmssite.com/2012/05/ezfind-shards</id>
    <content type="html"><![CDATA[<p><img src="https://s3.amazonaws.com/hs_blog_content/images/distributed_search.png" alt="Distributed Search" /></p>

<p>Prerequisites:
  eZ Publish with eZ Find installed</p>

<p>The following post is based on the option in the eZ Find <code>solr.ini</code> referring to Shards.</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
</pre></td><td class='code'><pre><code class='ini'><span class='line'><span class="k">[SolrBase]</span>
</span><span class='line'><span class="c1">#Shards mapping, can be to multicores in one servlet or even a crosss servers</span>
</span><span class='line'><span class="c1">#typical use is multilingual setups, but also for external index support</span>
</span><span class='line'><span class="c1">#the keys are used as shorthands in template functions</span>
</span><span class='line'><span class="c1">#Shards[]</span>
</span><span class='line'><span class="c1">#Shards[eng-GB]=http://localhost:8983/solr/eng-GB</span>
</span><span class='line'><span class="c1">#Shards[fre-FR]=http://localhost:8983/solr/fre-FR</span>
</span><span class='line'><span class="c1">#Shards[myforeignindex]=http://myotherhost:8983/solr</span>
</span></code></pre></td></tr></table></div></figure>


<p>What this means for eZ Find developers: we can do a distributed search in our standard eZ Find fetch (with a little work).</p>

<!--more-->


<p>First things first, we need to tell each siteaccess what its Search Server URI is. Within the <code>settings/siteaccess/&lt;siteaccess-name&gt;/</code> directory we need to create a new solr.ini.append.php file (duplicate the file in the admin version). Within each siteaccess we need to input our Solr core name; for harmssite it would be <code>SearchServerURI=http://localhost:8983/solr/harmssite</code> and for the counterhelix siteaccess it would be <code>SearchServerURI=http://localhost:8983/solr/counterhelix</code>.</p>

<p>Next, make sure that you have your cores installed into solr. In order to do this just copy the default eng-GB from the <code>solr.multicore/</code> directory and then rename it for each core you wish to have, in my case I have a harmssite and a counterhelix core. There is also a <code>solr.xml</code> that we need to edit. Here we declare each core that we created.</p>

<p>Mine:</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
</pre></td><td class='code'><pre><code class='xml'><span class='line'><span class="cp">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;</span>
</span><span class='line'><span class="nt">&lt;solr</span> <span class="na">persistent=</span><span class="s">&quot;true&quot;</span> <span class="na">sharedLib=</span><span class="s">&quot;lib&quot;</span><span class="nt">&gt;</span>
</span><span class='line'>  <span class="nt">&lt;cores</span> <span class="na">adminPath=</span><span class="s">&quot;/admin/cores&quot;</span><span class="nt">&gt;</span>
</span><span class='line'>    <span class="nt">&lt;core</span> <span class="na">name=</span><span class="s">&quot;harmssite&quot;</span> <span class="na">instanceDir=</span><span class="s">&quot;harmssite&quot;</span> <span class="nt">/&gt;</span>
</span><span class='line'>    <span class="nt">&lt;core</span> <span class="na">name=</span><span class="s">&quot;counterhelix&quot;</span> <span class="na">instanceDir=</span><span class="s">&quot;counterhelix&quot;</span> <span class="nt">/&gt;</span>
</span><span class='line'>  <span class="nt">&lt;/cores&gt;</span>
</span><span class='line'><span class="nt">&lt;/solr&gt;</span>
</span></code></pre></td></tr></table></div></figure>


<p>Finally, we need to start Solr, while giving it a new home parameter.</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>java -Dsolr.solr.home=solr.multicore -jar start.jar</span></code></pre></td></tr></table></div></figure>


<p>There is decent documentation on this up to this point located <a href="http://bit.ly/IYt5QI" title="eZ Find docs">here</a>.</p>

<p>Next, we need to add a list of our shards into our override <code>solr.ini.append.php</code> file. Use the demo from above, just put in the url each core. Something to note here. I believe the documentation is wrong here. We should not include the <code>http://</code> in this list, Solr will add this automatically for us when it runs the search. Thus, mine looks like this:</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='ini'><span class='line'><span class="k">[SolrBase]</span>
</span><span class='line'><span class="err">Shards</span><span class="k">[]</span>
</span><span class='line'><span class="na">Shards[harmssite]</span><span class="o">=</span><span class="s">localhost:8983/solr/harmssite</span>
</span><span class='line'><span class="na">Shards[counterhelix]</span><span class="o">=</span><span class="s">localhost:8983/solr/counterhelix</span>
</span></code></pre></td></tr></table></div></figure>


<p>I am assuming here that you know how to index your content, so update your search index to follow these settings. The next step is to set up a distributed search in our eZ Find fetch.</p>

<p>example:</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
</pre></td><td class='code'><pre><code class='smarty'><span class='line'><span class="cp">{</span><span class="nf">set</span> <span class="nv">$search</span><span class="o">=</span><span class="na">fetch</span><span class="o">(</span> <span class="s1">&#39;ezfind&#39;</span><span class="o">,</span> <span class="s1">&#39;search&#39;</span><span class="o">,</span>
</span><span class='line'>                    <span class="na">hash</span><span class="o">(</span> <span class="s1">&#39;query&#39;</span><span class="o">,</span> <span class="nv">$query</span><span class="o">,</span>
</span><span class='line'>                          <span class="s1">&#39;sort_by&#39;</span><span class="o">,</span> <span class="nv">$sort_by</span><span class="o">,</span>
</span><span class='line'>                          <span class="s1">&#39;facet&#39;</span><span class="o">,</span> <span class="nv">$defaultSearchFacets</span><span class="o">,</span>
</span><span class='line'>                          <span class="s1">&#39;filter&#39;</span><span class="o">,</span> <span class="nv">$filterParameters</span><span class="o">,</span>
</span><span class='line'>                          <span class="s1">&#39;publish_date&#39;</span><span class="o">,</span> <span class="nv">$search_date</span><span class="o">,</span>
</span><span class='line'>                          <span class="s1">&#39;offset&#39;</span><span class="o">,</span> <span class="nv">$view_parameters.offset</span><span class="o">,</span>
</span><span class='line'>                          <span class="s1">&#39;limit&#39;</span><span class="o">,</span> <span class="nv">$page_limit</span><span class="o">,</span>
</span><span class='line'>                          <span class="s1">&#39;as_objects&#39;</span><span class="o">,</span> <span class="kc">false</span><span class="o">(),</span>
</span><span class='line'>                          <span class="s1">&#39;distributed_search&#39;</span><span class="o">,</span> <span class="na">hash</span><span class="o">(</span>
</span><span class='line'>                              <span class="s1">&#39;shards&#39;</span><span class="o">,</span><span class="na">array</span><span class="o">(</span><span class="s1">&#39;harmssite&#39;</span><span class="o">,</span> <span class="s1">&#39;counterhelix&#39;</span><span class="o">)</span>
</span><span class='line'>                          <span class="o">)</span>
</span><span class='line'>                         <span class="o">))</span><span class="cp">}</span><span class="x"></span>
</span></code></pre></td></tr></table></div></figure>


<p>Note that we have to send the <code>distributed_search</code> parameter as a hashed array. In this case we are telling eZ Find to search both shards. We can have eZ Find search whatever core we want it to at this point, just harmssite, just counterhelix, both, or even new cores that we might add later. The advantages are obvious, separated indexes allowing for much larger sets of data is a huge upgrade. The downside is that searching multiple cores at once is a little slower, so really you should not use this option unless you are in need of scaling Solr out more; this would be a touch overkill for my site.</p>

<p>If you have followed me up to this point and have tried running this, you may have noticed that it does not work out of the box. The <code>ezfezpsolrquerybuilder.php</code> is still a work in process and has not been set up to handle shards just yet. Out of the box, should you send the distributed search shards array to eZ Find, eZ Find will take it, generate the shard urls and then do nothing with them. The task I leave you is to try and fix this problem for eZ Find. I have a fix for this, but would love to see what other people come up with (I will post my code here next week). The <a href="https://github.com/ezsystems/ezfind/blob/stable-2.7/classes/ezfezpsolrquerybuilder.php">file in question</a>. Remember, all we need to do is send the shards parameter to the search plugin should one be sent to eZ Find; the search plugin is already setup to handle shards.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[eZ Find: Enable Attribute Storage]]></title>
    <link href="http://harmssite.com/2012/04/ez-find-solr-attribute-storage/" />
    <updated>2012-04-26T00:00:00-05:00</updated>
    <id>http://harmssite.com/2012/04/ez-find-solr-attribute-storage</id>
    <content type="html"><![CDATA[<p><img src="https://s3.amazonaws.com/hs_blog_content/images/enable-solr-attribute-storage.png" alt="Enable Solr Attribute Storage" /></p>

<p>When using eZ Find to search a single local site, it does a really good job at building out the result object to be used. What becomes a problem, however, is when a cross-site search is necessary. When the search fetch includes <code>'as_objects', true()</code> eZ Find tries to build out an object by fetching from the database after the Solr search is completed and the necessary content is returned.</p>

<p>Another option, however, is to return all the information from Solr, no more object building from the DB. To do this all you have to do is enable <code>EnableSolrAttributeStorage</code> in the ezfind.ini. That way, if you are searching on a site that does not have access to the local database (cross-site search for instance) you can return all the content you need from Solr, because it is <em>all</em> stored.</p>

<p>So remember, set:
<code>'as_objects', false()</code> in the fetch.</p>

<p>and in the ezfind.ini</p>

<figure class='code'><figcaption><span>ezfind.ini </span></figcaption>
 <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='ini'><span class='line'><span class="k">[IndexOptions]</span>
</span><span class='line'><span class="na">EnableSolrAttributeStorage</span><span class="o">=</span><span class="s">true</span>
</span></code></pre></td></tr></table></div></figure>


<p>Then just remember to re-index your content to get all the new attributes in there.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Dogs Underwater]]></title>
    <link href="http://harmssite.com/2012/04/dogs-underwater/" />
    <updated>2012-04-23T00:00:00-05:00</updated>
    <id>http://harmssite.com/2012/04/dogs-underwater</id>
    <content type="html"><![CDATA[I am usually not one for email forwards. I got one today that I absolutely love, however. So, instead of re-forwarding it, I will share it here.

[nggallery id=2]

I found the original author of the pictures <a title="Underwater Dogs" href="http://www.littlefriendsphoto.com/index2.php" target="_blank">here</a> (the email had no information about the author).
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[eZ Find Multi-Core]]></title>
    <link href="http://harmssite.com/2012/04/ez-find-multi-core/" />
    <updated>2012-04-20T00:00:00-05:00</updated>
    <id>http://harmssite.com/2012/04/ez-find-multi-core</id>
    <content type="html"><![CDATA[<p>One of the greatest things about eZ Publish as a CMS is its ability to host many websites (siteaccesses) in one eZ Publish install. Recently I had the privilege of working on an eZ install that hosted 4 websites, giving the illusion of a single site experience across multiple urls. We used eZ Find extensively, specifically its multi-core functionality, to get information across the sites with ease. That way, all the sites can keep and maintain their own databases, and what is shared is shared through Solr.</p>

<div class="pull-right"><img title="solr-dir" src="https://s3.amazonaws.com/hs_blog_content/images/solr-dir.png" alt="Solr Directory" width="300" height="186" /></div>


<p>So, to start. Let&#8217;s assume that if you are reading this, you already read through my previous eZ Find tutorial (<a href="http://harmssite.com/2012/03/installing-ez-find/" title="Installing eZ Find">Installing eZ Find</a>). Since we already have our sever up and running there won&#8217;t be a lot of work to do there. But, we need to move our config files to the Solr multicore directory. Last time we used the Solr directory, this time we need to use the directory <code>solr.multicore</code>. Inside the multicore directory there are a couple of demo cores for languages. What I did is duplicated the english directory a couple times and renamed them for each site.</p>

<!--more-->


<p>I think this is the time for a nice FYI. We can go about this next part in a couple of different ways. The way we choose depends on the desired consequence. So, ask yourself this question, &#8216;Do I want the siteaccesses to share content?&#8217; If you answered yes, you only need 1 core for you sites to share off of, if you answered no, then create a core for each site that you wish to keep separate from the others. Another note, this effect can also be achieved by adjusting an ini setting, but if you know you want your stuff separate, then create multiple cores, it is safer that way. The way I set mine up is I have 2 cores. 1 core has 3 siteaccess sharing content, the other has just 1 site on it (that way its index content will not get mixed by accident).</p>

<p>Now that we are using Solr in a multi-core environment, starting Solr is a bit different.</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>java -Dsolr.solr.home<span class="o">=</span>solr.multicore -jar start.jar
</span></code></pre></td></tr></table></div></figure>


<p>Notice, we just sent the start.jar a new place for solr to call its&#8217; home directory <code>solr.multicore</code>.</p>

<p>Now that we have Solr re-configured for multi-core work we have to set up our solr.ini files. Inside the siteaccess specific override folders we need to drop in and edit a solr.ini.append.php file. Inside the ini file we need to point eZ Find at the right Solr cores.</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='ini'><span class='line'><span class="k">[SolrBase]</span>
</span><span class='line'><span class="na">SearchServerURI</span><span class="o">=</span><span class="s">http://localhost:8983/solr/&lt;core-name&gt;</span>
</span></code></pre></td></tr></table></div></figure>


<p>With that one ini setting set we can fully update our index with the same command as before (the update script inside the eZ Fnd extension). So, after we have that set there is 1 last setting that we need to set, it is inside the ezfind.ini.</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='ini'><span class='line'><span class="k">[SiteSettings]</span>
</span><span class='line'><span class="c1">#IndexPubliclyAvailable=disabled</span>
</span><span class='line'><span class="c1">#SearchOtherInstallations=disabled</span>
</span></code></pre></td></tr></table></div></figure>


<p>Notice that I have the settings commented it out here. I set it in the siteaccess specific override files, and if it is not commented out it overrides my content. Remember, this setting only applies to content that shares a core, if the content is not sharing a core it will not be able to search the other installations.</p>

<p>With this simple set of settings, we gain a lot of power over search. Combinations work here as well, if you don&#8217;t want to share the index, but want to search other available indexes, go for it.</p>

<p>Best of luck to you, if I missed something don&#8217;t be afraid to let me know. Also, if you have questions be sure to ask.</p>
]]></content>
  </entry>
  
</feed>
