# Hibernate Search with Elasticsearch

**URL:** <https://discuss.elastic.co/t/hibernate-search-with-elasticsearch/12402>\
**Category:** Elasticsearch\
**Created:** [June 13, 2013, 6:57pm UTC](https://discuss.elastic.co/t/hibernate-search-with-elasticsearch/12402 "2013-06-13T18:57:18Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zoran\_Jeremic](https://avatars.discourse-cdn.com/v4/letter/z/7ba0ec/32.png) [@Zoran\_Jeremic](https://discuss.elastic.co/u/Zoran_Jeremic)\
**Post date:** [June 13, 2013, 6:57pm UTC](https://discuss.elastic.co/t/hibernate-search-with-elasticsearch/12402/1 "2013-06-13T18:57:18Z")

</div>

Hi,

I have a project that uses Lucene, Tika and Hibernate search to index and  
search text, documents, web pages and Hibernate entities. I wanted to  
migrate to Elasticsearch and replace Lucene, but to keep Hibernate search  
for now. When I tried to put these two together I faced many difficulties  
related to the conflicts between different lucene versions in the backend.  
These problems disappeared after I commented all Hibernate Search  
dependencies and code referencing it. Is there any chance I can put these  
two in the same project working together without any conflicts? If so, what  
should I do?

Thanks,  
Zoran

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![roytmana](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/roytmana/32/44855_2.png) [@roytmana](https://discuss.elastic.co/u/roytmana)\
**Post date:** [June 13, 2013, 7:23pm UTC](https://discuss.elastic.co/t/hibernate-search-with-elasticsearch/12402/2 "2013-06-13T19:23:27Z")

</div>

Why not run elastic in a separate jvm?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Zoran\_Jeremic](https://avatars.discourse-cdn.com/v4/letter/z/7ba0ec/32.png) [@Zoran\_Jeremic](https://discuss.elastic.co/u/Zoran_Jeremic)\
**Post date:** [June 13, 2013, 7:35pm UTC](https://discuss.elastic.co/t/hibernate-search-with-elasticsearch/12402/3 "2013-06-13T19:35:29Z")

</div>

Maybe i didn't understand your idea very well. I'm trying to use java api  
to integrate elasticsearch with my application. At the moment I'm using  
local node during development as there are other guys who are working other  
things, so I don't want to bother them with configuring elasticsearch, but  
later I want to be able to switch to separate Amazon instance. So, I didn't  
even run elasticsearch server. The conflict is between elasticsearch client  
dependencies and hibernate search dependencies.

On Thursday, 13 June 2013 12:23:27 UTC-7, AlexR wrote:

> Why not run elastic in a separate jvm?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Erik\_Fassler\_2](https://avatars.discourse-cdn.com/v4/letter/e/9fc29f/32.png) [@Erik\_Fassler\_2](https://discuss.elastic.co/u/Erik_Fassler_2)\
**Post date:** [June 14, 2013, 6:25am UTC](https://discuss.elastic.co/t/hibernate-search-with-elasticsearch/12402/4 "2013-06-14T06:25:07Z")

</div>

This is a common problem since Lucene is such a wide-spread technology. I  
had this problem before and I opted for AlexR's proposal: Don't run two  
libraries dependent of Lucene in the same JVM. I even wouldn't recommend  
that if the Lucene versions were currently compatible: It might be that  
e.g. Elasticsearch rapidly develops forward and it actually is quite quick  
with adapting new Lucene versions. I don't know about Hibernate, but if you  
update to a newer Elasticsearch version but Hibernate still uses an older  
version of Lucene you could run into problems, even if your application is  
currently working. Or of course, you don't do updates.

Thus, why don't use an ES search server? You can start it on the same  
machine as your search application (or, if you want to, even on a different  
machine, your flexible, then) and use it via the Rest API, i.e. through the  
Client Java API. This should work very fine you woudn't have to bother with  
version conflicts.

On Thursday, 13 June 2013 21:35:29 UTC+2, Zoran Jeremic wrote:

> Maybe i didn't understand your idea very well. I'm trying to use java api  
> to integrate elasticsearch with my application. At the moment I'm using  
> local node during development as there are other guys who are working other  
> things, so I don't want to bother them with configuring elasticsearch, but  
> later I want to be able to switch to separate Amazon instance. So, I didn't  
> even run elasticsearch server. The conflict is between elasticsearch client  
> dependencies and hibernate search dependencies.
> 
> On Thursday, 13 June 2013 12:23:27 UTC-7, AlexR wrote:
> 
> > Why not run elastic in a separate jvm?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Zoran\_Jeremic](https://avatars.discourse-cdn.com/v4/letter/z/7ba0ec/32.png) [@Zoran\_Jeremic](https://discuss.elastic.co/u/Zoran_Jeremic)\
**Post date:** [June 14, 2013, 7:13am UTC](https://discuss.elastic.co/t/hibernate-search-with-elasticsearch/12402/5 "2013-06-14T07:13:47Z")

</div>

Hi Erik,

Thank you for your explanation. So you are suggesting that it's not  
possible to run those two together in the same application?

How about using Elasticsearch instead of Hibernate Search? I'm using  
Hibernate search to support search of the several different Hibernate  
entities based the user input in the input box and using a wildcard based  
search on the couple of the Hibernate entities. As the user type something  
in the textbox, a possible matches are displayed. Do you think it could be  
possible to implement search in elasticsearch (without hibernate-search)  
and then to query hibernate to pull the entity? I mean, I know it can be  
implemented, but would it be wise to apply this approach in terms of  
performances?

Zoran

On Thursday, 13 June 2013 23:25:07 UTC-7, Erik Fäßler wrote:

> This is a common problem since Lucene is such a wide-spread technology. I  
> had this problem before and I opted for AlexR's proposal: Don't run two  
> libraries dependent of Lucene in the same JVM. I even wouldn't recommend  
> that if the Lucene versions were currently compatible: It might be that  
> e.g. Elasticsearch rapidly develops forward and it actually is quite quick  
> with adapting new Lucene versions. I don't know about Hibernate, but if you  
> update to a newer Elasticsearch version but Hibernate still uses an older  
> version of Lucene you could run into problems, even if your application is  
> currently working. Or of course, you don't do updates.
> 
> Thus, why don't use an ES search server? You can start it on the same  
> machine as your search application (or, if you want to, even on a different  
> machine, your flexible, then) and use it via the Rest API, i.e. through the  
> Client Java API. This should work very fine you woudn't have to bother with  
> version conflicts.
> 
> On Thursday, 13 June 2013 21:35:29 UTC+2, Zoran Jeremic wrote:
> 
> > Maybe i didn't understand your idea very well. I'm trying to use java api  
> > to integrate elasticsearch with my application. At the moment I'm using  
> > local node during development as there are other guys who are working other  
> > things, so I don't want to bother them with configuring elasticsearch, but  
> > later I want to be able to switch to separate Amazon instance. So, I didn't  
> > even run elasticsearch server. The conflict is between elasticsearch client  
> > dependencies and hibernate search dependencies.
> > 
> > On Thursday, 13 June 2013 12:23:27 UTC-7, AlexR wrote:
> > 
> > > Why not run elastic in a separate jvm?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 14, 2013, 8:13am UTC](https://discuss.elastic.co/t/hibernate-search-with-elasticsearch/12402/6 "2013-06-14T08:13:39Z")

</div>

Hey Zoran,

In my former company I started with an HBSearch project. Then I discovered Elasticsearch and put all that HBSearch stuff away.  
In my service layer, basically, each time I was persisting my main entities with merge, save or delete, I:

- Serialize the javabean to JSon with Jackson
- Send it to Elasticsearch

That's it.

For searches, I add to adapt my HBSearch code to an ES code (using ES Query DSL instead of Criteria).

So my advice here is to use ES only as your search engine and not try to combine both.

My 2 cents

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 14 juin 2013 à 09:13, Zoran Jeremic [zoran.jeremic@gmail.com](mailto:zoran.jeremic@gmail.com) a écrit :

> Hi Erik,
> 
> Thank you for your explanation. So you are suggesting that it's not possible to run those two together in the same application?
> 
> How about using Elasticsearch instead of Hibernate Search? I'm using Hibernate search to support search of the several different Hibernate entities based the user input in the input box and using a wildcard based search on the couple of the Hibernate entities. As the user type something in the textbox, a possible matches are displayed. Do you think it could be possible to implement search in elasticsearch (without hibernate-search) and then to query hibernate to pull the entity? I mean, I know it can be implemented, but would it be wise to apply this approach in terms of performances?
> 
> Zoran
> 
> On Thursday, 13 June 2013 23:25:07 UTC-7, Erik Fäßler wrote:  
> This is a common problem since Lucene is such a wide-spread technology. I had this problem before and I opted for AlexR's proposal: Don't run two libraries dependent of Lucene in the same JVM. I even wouldn't recommend that if the Lucene versions were currently compatible: It might be that e.g. Elasticsearch rapidly develops forward and it actually is quite quick with adapting new Lucene versions. I don't know about Hibernate, but if you update to a newer Elasticsearch version but Hibernate still uses an older version of Lucene you could run into problems, even if your application is currently working. Or of course, you don't do updates.
> 
> Thus, why don't use an ES search server? You can start it on the same machine as your search application (or, if you want to, even on a different machine, your flexible, then) and use it via the Rest API, i.e. through the Client Java API. This should work very fine you woudn't have to bother with version conflicts.
> 
> On Thursday, 13 June 2013 21:35:29 UTC+2, Zoran Jeremic wrote:  
> Maybe i didn't understand your idea very well. I'm trying to use java api to integrate elasticsearch with my application. At the moment I'm using local node during development as there are other guys who are working other things, so I don't want to bother them with configuring elasticsearch, but later I want to be able to switch to separate Amazon instance. So, I didn't even run elasticsearch server. The conflict is between elasticsearch client dependencies and hibernate search dependencies.
> 
> On Thursday, 13 June 2013 12:23:27 UTC-7, AlexR wrote:  
> Why not run elastic in a separate jvm?
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Erik\_Fassler\_2](https://avatars.discourse-cdn.com/v4/letter/e/9fc29f/32.png) [@Erik\_Fassler\_2](https://discuss.elastic.co/u/Erik_Fassler_2)\
**Post date:** [June 14, 2013, 10:47am UTC](https://discuss.elastic.co/t/hibernate-search-with-elasticsearch/12402/7 "2013-06-14T10:47:00Z")

</div>

Hi Zoran,

I would go the way David recommended to you. Don't worry about the  
performance, for the usecase you described I absolutely expect real-time  
responses. Because Elasticsearch is made for such tasks.  
And David's approach is very easy to implement since Elasticsearch  
understands documents that actually are JSON objects, how much better can  
it be?

On Friday, 14 June 2013 09:13:47 UTC+2, Zoran Jeremic wrote:

> Hi Erik,
> 
> Thank you for your explanation. So you are suggesting that it's not  
> possible to run those two together in the same application?
> 
> How about using Elasticsearch instead of Hibernate Search? I'm using  
> Hibernate search to support search of the several different Hibernate  
> entities based the user input in the input box and using a wildcard based  
> search on the couple of the Hibernate entities. As the user type something  
> in the textbox, a possible matches are displayed. Do you think it could be  
> possible to implement search in elasticsearch (without hibernate-search)  
> and then to query hibernate to pull the entity? I mean, I know it can be  
> implemented, but would it be wise to apply this approach in terms of  
> performances?
> 
> Zoran
> 
> On Thursday, 13 June 2013 23:25:07 UTC-7, Erik Fäßler wrote:
> 
> > This is a common problem since Lucene is such a wide-spread technology. I  
> > had this problem before and I opted for AlexR's proposal: Don't run two  
> > libraries dependent of Lucene in the same JVM. I even wouldn't recommend  
> > that if the Lucene versions were currently compatible: It might be that  
> > e.g. Elasticsearch rapidly develops forward and it actually is quite quick  
> > with adapting new Lucene versions. I don't know about Hibernate, but if you  
> > update to a newer Elasticsearch version but Hibernate still uses an older  
> > version of Lucene you could run into problems, even if your application is  
> > currently working. Or of course, you don't do updates.
> > 
> > Thus, why don't use an ES search server? You can start it on the same  
> > machine as your search application (or, if you want to, even on a different  
> > machine, your flexible, then) and use it via the Rest API, i.e. through the  
> > Client Java API. This should work very fine you woudn't have to bother with  
> > version conflicts.
> > 
> > On Thursday, 13 June 2013 21:35:29 UTC+2, Zoran Jeremic wrote:
> > 
> > > Maybe i didn't understand your idea very well. I'm trying to use java  
> > > api to integrate elasticsearch with my application. At the moment I'm using  
> > > local node during development as there are other guys who are working other  
> > > things, so I don't want to bother them with configuring elasticsearch, but  
> > > later I want to be able to switch to separate Amazon instance. So, I didn't  
> > > even run elasticsearch server. The conflict is between elasticsearch client  
> > > dependencies and hibernate search dependencies.
> > > 
> > > On Thursday, 13 June 2013 12:23:27 UTC-7, AlexR wrote:
> > > 
> > > > Why not run elastic in a separate jvm?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Zoran\_Jeremic](https://avatars.discourse-cdn.com/v4/letter/z/7ba0ec/32.png) [@Zoran\_Jeremic](https://discuss.elastic.co/u/Zoran_Jeremic)\
**Post date:** [June 14, 2013, 5:12pm UTC](https://discuss.elastic.co/t/hibernate-search-with-elasticsearch/12402/8 "2013-06-14T17:12:48Z")

</div>

Hi guys,

Thank you for your advices. I'll try the approach David suggested.

Best,  
Zoran

On Friday, 14 June 2013 03:47:00 UTC-7, Erik Fäßler wrote:

> Hi Zoran,
> 
> I would go the way David recommended to you. Don't worry about the  
> performance, for the usecase you described I absolutely expect real-time  
> responses. Because Elasticsearch is made for such tasks.  
> And David's approach is very easy to implement since Elasticsearch  
> understands documents that actually are JSON objects, how much better can  
> it be?
> 
> On Friday, 14 June 2013 09:13:47 UTC+2, Zoran Jeremic wrote:
> 
> > Hi Erik,
> > 
> > Thank you for your explanation. So you are suggesting that it's not  
> > possible to run those two together in the same application?
> > 
> > How about using Elasticsearch instead of Hibernate Search? I'm using  
> > Hibernate search to support search of the several different Hibernate  
> > entities based the user input in the input box and using a wildcard based  
> > search on the couple of the Hibernate entities. As the user type something  
> > in the textbox, a possible matches are displayed. Do you think it could be  
> > possible to implement search in elasticsearch (without hibernate-search)  
> > and then to query hibernate to pull the entity? I mean, I know it can be  
> > implemented, but would it be wise to apply this approach in terms of  
> > performances?
> > 
> > Zoran
> > 
> > On Thursday, 13 June 2013 23:25:07 UTC-7, Erik Fäßler wrote:
> > 
> > > This is a common problem since Lucene is such a wide-spread technology.  
> > > I had this problem before and I opted for AlexR's proposal: Don't run two  
> > > libraries dependent of Lucene in the same JVM. I even wouldn't recommend  
> > > that if the Lucene versions were currently compatible: It might be that  
> > > e.g. Elasticsearch rapidly develops forward and it actually is quite quick  
> > > with adapting new Lucene versions. I don't know about Hibernate, but if you  
> > > update to a newer Elasticsearch version but Hibernate still uses an older  
> > > version of Lucene you could run into problems, even if your application is  
> > > currently working. Or of course, you don't do updates.
> > > 
> > > Thus, why don't use an ES search server? You can start it on the same  
> > > machine as your search application (or, if you want to, even on a different  
> > > machine, your flexible, then) and use it via the Rest API, i.e. through the  
> > > Client Java API. This should work very fine you woudn't have to bother with  
> > > version conflicts.
> > > 
> > > On Thursday, 13 June 2013 21:35:29 UTC+2, Zoran Jeremic wrote:
> > > 
> > > > Maybe i didn't understand your idea very well. I'm trying to use java  
> > > > api to integrate elasticsearch with my application. At the moment I'm using  
> > > > local node during development as there are other guys who are working other  
> > > > things, so I don't want to bother them with configuring elasticsearch, but  
> > > > later I want to be able to switch to separate Amazon instance. So, I didn't  
> > > > even run elasticsearch server. The conflict is between elasticsearch client  
> > > > dependencies and hibernate search dependencies.
> > > > 
> > > > On Thursday, 13 June 2013 12:23:27 UTC-7, AlexR wrote:
> > > > 
> > > > > Why not run elastic in a separate jvm?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 2:31am UTC](https://discuss.elastic.co/t/hibernate-search-with-elasticsearch/12402/9 "2017-07-06T02:31:10Z")

</div>


