{ by david linsin }

December 03, 2006

Compass - A Hibernate Lucene Integration

I've been following the Hibernate Lucene integration plans of JBoss for a while now and I came across the Compass framework, which seems to be very interesting:
The aim of Compass is to simplify the integration of search functionality into any application. Compass is built on top of Lucene using a well defined search engine abstraction. Compass extends core Lucene and adds transaction support and fast updates, as well as the ability to store the index in the database. Also, most importantly, it does not try to hide Lucene's features - all of Lucene's functionality is available through Compass.

The framework consists of a core API, which is similar to the Hibernate API, handling configuration, search engine operations and transactional support. Furthermore it provides a module called Compass GPS aiming at integration with various data sources. Among others it provides intgeration with ORM tools like Hibernate.
...Compass introduces two main operations: Indexing and Mirroring. Indexing allows to automatically index the database content using both Hibernate mappings and Compass mappings. Objects that have both mappings will be automatically fetched from the database using Hibernate and saved into the search engine. Mirroring allows to automatically mirror operations done using Hibernate API into the search engine by registering event listeners with Hibernate. This allows to keep the index up to date with any changes done to the database through Hibernate API.

One thing, that I've already been worried about previously, is performance. How does this synchronization perform under heavy load? Another point are transaction boundaries, since there are two data source that need to be updated when performing changes. Does a transaction fail cause your application's Lucene index couldn't be updated?

Though I haven't checked out Compass myself, I believe it extends Lucene in a really cool way. Minimizing the boilerplate code to map your domain objects to Lucene documents is one of these great extensions. Another nice feature is the integration with Hibernate in very transparent fashion, so no additional code is necessary to keep your Lucene index snychronized.



  • mail(dlinsin@gmail.com)
  • jabber(dlinsin@gmail.com)
  • skype(dlinsin)