Java – Configuring Compass with Annotated Hibernate

compass-lucenehibernatejavalucenespring

I'm using Hibernate for a Java-based Web Application and want to add full-text search via Compass. Compass is supposed to support that, but fails to provide any useful Getting Started guide.

I could figure out that I have to annotate my Entities with @Searchable and the various @SearchableXXX variations and accessing Compass in my service code via HibernateHelper.getCompass(sessionFactory).

I end up with a HibernateException saying "Compass event listeners not configured, please check the reference documentation and the application's hibernate.cfg.xml".

The reference documentation again hints and hibernate.cfg.xml, while I configure Hibernate with Spring's AnnotationSessionFactoryBean. For that case, the documetantation mentions: "If Hibernate Annotations or Hibernate EntityManager (JPA) are used, just dropping Compass jar file to the classpath will enable it (make sure you don't have Hibernate Search in the classpath, as it uses the same event class name)." That doesn't work for me.

Any ideas whats I'm missing or a good resource for getting started?

Best Answer

I'm wondering why you chose Compass to go Hibernate. We looked at Compass and Hibernate-Search and we chose the latter as it has excellent integration.

You can query the test index in exactly the same way you do an SQL database with HQL or Critera.

If you were using iBatis or JDBC then Compass would of course be the better fit. Hibernate search is a better fit with JTA.

Is it me or is Compass suffering from a distinct lack of activity?