2

I have a simply question, because today it was the first time I met and used Hibernate Search. Can somebody explain me simply what are the adventages of using Hibernate Search with JPA annotations, does it make sense to use it instead of Spring Data ( I mean CRUD/JPA repositories )? When is Hibernate Search most profitable?

E.g. I have simple SpringMVC webapp, with Users and Events. User should be able to view lists of events on pages, with sorting option.

He should be able to search for specific events by given "fields". In that case should I use CRUD/JPA repos or work with Hib Search?

Thank you in advance!

cнŝdk
  • 28,676
  • 7
  • 47
  • 67
crooked
  • 603
  • 2
  • 11
  • 22

2 Answers2

3

As you can see in the documentation, Hibernate Search is mainly used for full text search, clustering and indexing results rather than just fetching database tables which is naturally provided with Spring data, HQL and Criteria API...

So in this case Hibernate Search is used for high-performance text search and plays the role of a text search engine (Lucene, Sphinx...).

In your case:

So if you are developing a basic web application where you just need to query some entities from the database, you should simply use Spring data, JPQL, core Hibernate HQL or Criteria API.

cнŝdk
  • 28,676
  • 7
  • 47
  • 67
1

There are a number of good articles on this. An example can be found here. However in the interests of a non-link answer you should use Hibernate search if the majority of your searching is full text (fuzzy searches, wildcards, geospatial etc.) Otherwise if you're more interested in DB joins, sorts etc. just use SQL.

Alex Barnes
  • 7,096
  • 1
  • 26
  • 48
  • So e.g. when I have a lot of Events descriptions and comments then I should use Hibernate Search? And in case of simply displaying Events from DB i should use SQL, right? – crooked Apr 07 '17 at 21:23
  • Agreed. If you're searching descriptions/comments then a full text search would be useful. For simply listing data then SQL is probably best. – Alex Barnes Apr 07 '17 at 21:24