Posts Tagged ‘solr’

Grails Solr Plugin Progress Screencast

March 3rd, 2010

I started work on this plugin back in December based on the work I did for Patheos.com and by the graces of my employer Avalon Consulting LLC and Patheos, they allowed me to open source the plugin and continue working on it. This week I had some time to get back to it, and today I started creating a basic reference implementation application that will accompany the documentation. Below is a screencast demo of this application which indexes an export of songs from my iTunes library metadata and makes them searchable.

The code for the plugin is at Github and is still a work in progress.  I’m pushing towards a 0.1 release next week with the bulk of the work I still need to do in the form of documentation and clean-up.

So please watch the screencast, and I would love feedback.  I will certainly take offers to help continue the development of the plugin but would like to get 0.1 out first to round out my train of thought and not further delay that basic milestone.

Grails Solr Plugin pre-0.1 Demo from mbrevoort on Vimeo.

DOSUG Solr in 5 Minutes Ingnite Presentation

February 4th, 2010

On Tuesday (2/2/2010) I participated in the Denver Open Source User Group’s first Ignite night. My presentation was an quick overview of Solr, the java based open-source search engine. This was my first Ignite style presentation, and the format is challenging! The presentations were each 5 minutes with a 20 slide deck auto advancing every 15 seconds. I stumbled a bit out of the gate with the cold start but was able to get it back on the rails though I felt as if I was trying to dig myself out of quicksand through the rest of it. Overall it was a lot of fun.

The room was packed, somewhere in the neighborhood of 100 people, and overall the quality of the presentations were very good. You can check out the slide decks on Slideshare here. Here are my slides:

And here is a dry-run of my presentation I recorded while practicing the day of:

Annotations with Grails

December 29th, 2009

Recently I’ve been heads down writing a Grails Solr plugin for using Solr to index and search Grails domain objects, content and other documents. I share more on that in the next several day and weeks.  While doing so I implement annotations for the first time. In this example, I create an annotation type that lets you annotate a class property to specify a custom Solr index field name.  In usage it looks like this:

import org.grails.plugins.solr.Solr
class aDomain {
  @Solr(field="thedomainstitle")
  String title
}

The imported class above is actually an interface that defines the annotation:

package org.grails.plugins.solr
import java.lang.annotation.*

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface Solr {
  String field();
}

This is fairly self explanatory. The name of the annotation is “Solr” and there is one propery field with a value of String. Almost identical to the java equivalent.

Now to access the annotation value for the field, you simply need the get a reference to the annotation and call the method on it defined above: field(). So with a bit of context below, I define an indexSolr() method for each domain class, loop through each property and check if there is an annotation of Solr defined for the field, if so I set the value of field() to the docKey which is used as the Solr field name for the property.

application.domainClasses.each { dc ->
  dc.metaClass.indexSolr < < { ->
    //.......
    application.getArtefact(DomainClassArtefactHandler.TYPE, delegate.class.name).getProperties().each {
      //.......
      def theField = delegate.class.declaredFields.find{ field -> field.name == it.name}

      if(theField.isAnnotationPresent(Solr)) {
        docKey = theField.getAnnotation(Solr).field()
      }
      //........
    }
    //........
  }
}

Powerful, yet simple.

Powered by Web Design Company Plugins

Switch to our mobile site