Hibernate Search vs spring-data-solr , spring-data-elasticsearch
Asked Answered
E

1

8

I have a spring boot, Spring Data JPA (hibernate) web application and want to introduce text search feature.

I understand the following

  • Both hibernate search or spring-data-* can be integrated into my app

  • Hibernate search can work with embedded Lucene or external elastic search.

  • External elastic search/ solr has its own benefits, but I am ok with

    embedded also to start with.

My questions

  • Which library is better for easy development and maintenance.
  • I see many pros and cons of solr vs elasticsearch but need Pros and Cons of Hibernate search vs spring-data-*
  • I found an example on introducing Hibernate Search in an existing application. but nothing on spring-data-, how to reindex or trigger indexing of existing database data in spring-data-
Erythrocyte answered 21/12, 2017 at 5:31 Comment(0)
A
10

I'm obviously biased since I am a Hibernate developer, but I can at least provide some elements focused on Hibernate Search. As to which is "better", that's for you to judge.

The main difference is that Hibernate Search provides integration between JPA and your index of choice (Lucene or Elasticsearch):

  • Hibernate Search will automatically add/update/delete documents in your full-text index according to changes in your JPA entities (as soon as you commit a transaction).
  • Hibernate Search will allow you to build a full-text query (full-text world), and retrieve the results as managed entities (JPA world).

As far as I understand, Spring-Data-Elasticsearch is focused on accessing Elasticsearch and has no JPA integration whatsoever. That is to say, you can use Spring-Data-JPA, and you can use Spring-Data-Elasticsearch, but they won't communicate with each other. You will have two separate models, which you will update and query separately.

Some other elements:

  • If you don't need a distributed index, Hibernate Search can run in embedded Lucene mode, without all the Elasticsearch stack. It will probably be more lightweight.
  • Hibernate Search is currently not very flexible when it comes to customizing your Elasticsearch mapping or using advanced Elasticsearch features, because of the abstraction layer. EDIT: That's no longer true now that Hibernate Search 6 has been released.
  • A Spring-Data-HibernateSearch module has been worked on in the past, but is no longer actively maintained: https://github.com/snowdrop/spring-boot-hibernate-search-booster
Arela answered 21/12, 2017 at 8:29 Comment(2)
Hi yrodiere, Is it possible to build multi-index queries through Hibernate Search 7. e.g. Green Hat, there are three index/entities, Brand, Categories and Products. Brand=Green, Category=Hats, Product=Small Ladies Green Hat. And Result order would be brand, category and then products. i.e. Search "Green Hat" in brands, categories and products in one go, and return results from all three but priority on top is brand then category (any matched) and then product (any matched). Is that possible with hibernate search. If so Can you give some hints on such queryBeetner
Hi. Please ask a separate question, comments are no way to handle this kind of conversation.Arela

© 2022 - 2024 — McMap. All rights reserved.