2

We had previously used hibernate search, Lucene for indexing.
To provide better scalability, we are planning to use Elasticsearch 5(instead of Lucene).

I have following questions:

  1. Is there any explicit hibernatesearch java api to feed the data to Elasticsearch?
  2. Are there any challenges to use Hibernate search and Elasticsearch together?
Airn5475
  • 2,452
  • 29
  • 51

2 Answers2

3

Is there any explicit hibernatesearch java api to feed the data to Elastic search?

AFAIK you can just use the standard HibernateSearch API to send your data to Elasticsearch instead of Lucene. It's pretty much transparent for you. At query time, you can do both. Use standard HibernateSearch queries or use native elasticsearch queries:

FullTextEntityManager fullTextEm = Search.getFullTextEntityManager(entityManager);
QueryDescriptor query = ElasticsearchQueries.fromJson(
      "{ 'query': { 'match' : { 'lastName' : 'Brand' } } }");
List<?> result = fullTextEm.createFullTextQuery(query, GolfPlayer.class).getResultList();

You can also get an access to the Elasticsearch Client.

Are there any challenges to use Hibernate search and elastic search together?

I think the Hibernate Search team is doing a very good job. It includes transparency like listing the known limitations of the implementation.

dadoonet
  • 14,109
  • 3
  • 42
  • 49
  • Thanks for the quick reply. We are planning to use Kafka as the Broker. Our Application is the producer, sends the message object to Kafka including hibernate mapping details. Elastic search is the consumer. Does Elastic search indexes as per hibernate search mappings once it receives the data from Kafka? – hithendra sharma May 18 '18 at 20:05
  • This is another question to me. I think it's better to ask for it with an example in another question – dadoonet May 19 '18 at 01:10
  • I already asked here. https://stackoverflow.com/questions/50378895/hibernate-search-kafka-elatic-search. Can you please answer my questions? – hithendra sharma May 23 '18 at 04:30
  • Please answer my questions whenever you get a chance – hithendra sharma May 24 '18 at 18:14
0

I believe using Elastic Search in JPA style, All inbuilt method can be used.

Let me know if needed sample code.

public interface YourClass extends ElasticsearchRepository<Object, String>{}

pom.xml:

<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-elasticsearch</artifactId>
    <version>3.0.8.RELEASE</version>
</dependency>
jannis
  • 4,843
  • 1
  • 23
  • 53
Swarit Agarwal
  • 2,520
  • 1
  • 26
  • 33