Programming : Using Lucene to full-text index a domain model

This page last changed on Mar 21, 2006 by Kees de Kooter

My solution consists of the following components

  1. an xml file describing the objects and attributes to indexed and the url with which they can be viewed
  2. a Hibernate interceptor that catches changes to domain objects
  3. an indexer component performing the actual indexing
  4. a search component for searching the index

TODO: add code snippets

This solution was written last year. In the meantime the compass framework ( was launched. This framework offers some valuable features: transaction support, use of a jdbc based backend, and a default "All" field.

Compass's hibernate implementation indexes and repopulates domain objects. In my view not always a desirable solution. I want to display a simple textual view of a search result containing several different types of domain objects. I just want to print summaries basically, I do not want to do a lot of type checking in my search result page.

The compass solution is to use their (lower level) Resource type of indexing, for which you have to write your own code for populating the fields (or rather Property in compass-speak). So I guess there is room for my solution after all.