Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Lucene and JPA?

I would like to use Lucene to provide full text search capability on some of my java objects stored with EclipseLink in my Postgresql database.

I saw Hibernate has an integrated solution for Lucene called Hibernate Search, but I can't find anything for EclipseLink. Is there a solution out there for EclispeLink? if not I have a vague idea of what I should do to handle Lucene indexing when adding and removing objects but I would really appreciate if somebody could provide me with a nice tutorial on this topic.

Thanks in advance,

Thomas

like image 820
Thomas Avatar asked Jan 16 '12 15:01

Thomas


1 Answers

There WAS Compass. However, it was a one-man project, and that developer stopped working on it back in 2009. He moved on to another one-man project, called ElasticSearch.

That project is a standalone search engine, competing with Apache Solr... rather than an embedded library competing with Apache Lucene and Hibernate Search.

Unfortunately, I don't really know of any other serious alternatives for integrating EclipseLink with Apache Lucene. EclipseLink has gathered a lot of mindshare since Oracle changed its name from TopLink, gave it away, and declared it to be a reference implementation. EclipseLink MOXy is a fantastic JAX-B implementation with some really cool extensions. However, for core database interaction... Hibernate is still the more mature and adopted JPA implementation by a mile.

On the other hand, the Hibernate Search wrapper for Lucene does support using Hibernate in JPA 2 mode rather than its classic API. In my opinion, it integrates a bit cleaner with JPA rather than the old Hibernate API anyway.

So unless you're using proprietary EclipseLink extensions that have you locked-in, you might consider swapping out your JPA provider if you want easy Lucene integration. If your entity classes are already JPA-annotated, it should be a simple matter of updating your persistence.xml file (and your Maven POM, or however you manage your JAR dependencies).

like image 63
Steve Perkins Avatar answered Sep 28 '22 07:09

Steve Perkins