lunedì 25 maggio 2009

Hibernate Search: the one who searches, he will found

This time i will explore full text search in Java, and particularly Hibernate Search.

Hibernate Search (or HS) builds on top of Apache Lucene, the famous java search engine used by many opensource and commercial projects.

HS enhances Lucene providing:
  • transparent indexing capabilities for persistent entities
  • a flexible architecture
What does transparent indexing capabilities means?

Instead of forcing the developer to use the Lucene API for indexing data, hence a programmatical approach, HS foster a declarative approach: through annotations you can specify that an Entity should be indexed and which fields should be indexed and how (which analizer to use, whether to store it or not, etc.).

HS will keep an eye on the persistent context and transparently index any entity that is added, removed and modified through it.

Since i am a great fan of the declarative approach and annotations, this is great news for me!

Beside this, HS has a flexible architecture, allowing to customize indexing strategies in order to balance between consistency and performance.

BACK-END MODE
For dealing with clustered environments, HS offers the following alternatives:
  • Lucene Mode: the index is on a shared directory (i.e. NFS) that is accesed by every cluster node
  • JMS Mode: any modification is sent to a JMS queue that updates a master index; any search is done on a local copy of the index; this copy is periodically refreshed from the master index
The Lucene Mode is the default and is also used for non clustered environment, usually with a local directory (no need for the index to be on NFS if there is no cluster).

With Lucene Mode index updates are in real-time, granting maximum consistency.
With JMS Mode index updates are delayed, but the application is not locked, granting maximum performance.

More to come....

1 commento:

uccio82 ha detto...

ottimo articolo!