Is Hibernate Search a clean abstraction for Lucene?

Go To StackoverFlow.com

1

I have used Hibernate in the past and I share many people's frustration with using an ORM. Since traditional databases are relational, any ORM has a leaky abstraction. Much of my time ends up being used to understand the details of the abstraction so I can achieve good performance.

Hibernate Search however works on top of Lucene. Since Lucene contains a collection of documents of the same types, it might not have the same problems as Hibernate with a relational database. Does Hibernate Search provide a clean abstraction, or is Hibernate Search fraught with the same problems as Hibernate+MySQL?

I'm considering moving from an existing implementation in raw Lucene to Hibernate Search.

2012-04-05 16:08
by schmmd
I think your argument of leaky abstraction applies for search as well. it is trying to represent the document as an entity. You might also want to check elasticsearch which is built on top of Lucene - Aravind R. Yarram 2012-04-05 16:12
I don't see major problems representing a document as an entity. As an example leak in ORMs, in Hibernate if you have the one-to-many side as the owner, inserts add the children with a null reference to the parent, but if the many-to-one side owns the relationship, then the children are inserted with the reference to the parent (which is much faster) - schmmd 2012-04-05 16:18


2

A good abstraction is an abstraction which solves a problem which is not addressed by the underlying library with no or little compromise on the feature set. In case of Lucene, these problems could be:

  • index distribution,
  • synchronization with another persisted data source,
  • ...

Then, the best abstraction depends on this problem you need to solve:

  • If you just want to be able to build a reverse index on a single server and query it, then stick to plain Lucene. Lucene is already the best abstraction available. Any other abstraction would add overhead while probably preventing you from using some features and not making things much easier.

  • If you want to go distributed, then Solr or Elastic Search would help you a lot.

  • If you want to integrate full-text functionality with another persisted data set, then Hibernate Search or Compass could be interesting candidates.

2012-04-06 10:24
by jpountz
Thank you, this is extremely helpful. We may want to store some data in a relational database. In that case, I'll investigate Hibernate Search's capabilities for that. Otherwise, we'll stick to Lucene - schmmd 2012-04-06 16:28
Ads