# Java entities in and out and collection types

**URL:** <https://discuss.elastic.co/t/java-entities-in-and-out-and-collection-types/6571>\
**Category:** Elasticsearch\
**Created:** [February 2, 2012, 5:06am UTC](https://discuss.elastic.co/t/java-entities-in-and-out-and-collection-types/6571 "2012-02-02T05:06:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dennis](https://avatars.discourse-cdn.com/v4/letter/d/e56c9b/32.png) [@Dennis](https://discuss.elastic.co/u/Dennis)\
**Post date:** [February 2, 2012, 5:06am UTC](https://discuss.elastic.co/t/java-entities-in-and-out-and-collection-types/6571/1 "2012-02-02T05:06:58Z")

</div>

Sorry, I'm not that great at java, and now a beginner in elastic  
search. From what I can tell, ES is just what I need for a project.

So, I'd like to make a facade class that has the usual CRUD-and-Find/  
Search methods. it will keep the ES and DB in sync, transparent to the  
facade class's client.

I'd like to have both JSON and Java Entities for IO to the facade  
class.

Just for clarification purposes, there's no built in functionality in  
the Java API to take a java object/entity and index it, right? Nor  
Lists and other collections? ES itself takes all JSON, right? So I  
have to have a Jackson inteface layer between the Facade class's  
private ES client attribute and any Java manipulation, right?

Normally, for those on this list who might know, what does JPA/  
Hibernate return for a collection?

---

<div class="post-metadata">

**Author:** ![louis\_gueye](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/louis_gueye/32/2772_2.png) [@louis\_gueye](https://discuss.elastic.co/u/louis_gueye)\
**Post date:** [February 2, 2012, 9:20am UTC](https://discuss.elastic.co/t/java-entities-in-and-out-and-collection-types/6571/2 "2012-02-02T09:20:32Z")

</div>

One question at a time.

To serialize a java object to json and vice versa you have to use a  
library. Jackson is a good one (not the only one).

ES can index byte arrays : byte. That indexation is fast. So you can  
convert your json object to byte array and provide ES with that input.

For a full working example which uses Hibernate+JPA+Spring+ES+Byte array  
converters you can read this article series

> **[Add search features to your application, try Elasticsearch part 1 : the concepts](https://deepintojee.wordpress.com/2012/01/20/add-search-features-to-your-application-try-elasticsearch-part-1-the-concepts/)**
>
> Hi all, The ultimate goal of a search engine is to provide fast, reliable, easy to use, scalable search features to a software. But before diving into complex and technical considerations we should…

Hope this helps.

2012/2/2 Dennis [gearond@gmail.com](mailto:gearond@gmail.com)

> Sorry, I'm not that great at java, and now a beginner in elastic  
> search. From what I can tell, ES is just what I need for a project.
> 
> So, I'd like to make a facade class that has the usual CRUD-and-Find/  
> Search methods. it will keep the ES and DB in sync, transparent to the  
> facade class's client.
> 
> I'd like to have both JSON and Java Entities for IO to the facade  
> class.
> 
> Just for clarification purposes, there's no built in functionality in  
> the Java API to take a java object/entity and index it, right? Nor  
> Lists and other collections? ES itself takes all JSON, right? So I  
> have to have a Jackson inteface layer between the Facade class's  
> private ES client attribute and any Java manipulation, right?
> 
> Normally, for those on this list who might know, what does JPA/  
> Hibernate return for a collection?

--  
Cordialement/Regards,

Louis GUEYE  
linkedin [http://fr.linkedin.com/in/louisgueye](http://fr.linkedin.com/in/louisgueye) |  
blog[http://deepintojee.wordpress.com/](http://deepintojee.wordpress.com/)|  
twitter [http://twitter.com/#!/lgueye](http://twitter.com/#%21/lgueye)

---

<div class="post-metadata">

**Author:** ![Dennis](https://avatars.discourse-cdn.com/v4/letter/d/e56c9b/32.png) [@Dennis](https://discuss.elastic.co/u/Dennis)\
**Post date:** [February 2, 2012, 4:22pm UTC](https://discuss.elastic.co/t/java-entities-in-and-out-and-collection-types/6571/3 "2012-02-02T16:22:33Z")

</div>

NICE article! Thank you for the pointer. I didn't know that Wordpress  
was in Java!

On Feb 2, 1:20 am, louis gueye [louis.gu...@gmail.com](mailto:louis.gu...@gmail.com) wrote:

> One question at a time.
> 
> To serialize a java object to json and vice versa you have to use a  
> library. Jackson is a good one (not the only one).
> 
> ES can index byte arrays : byte. That indexation is fast. So you can  
> convert your json object to byte array and provide ES with that input.
> 
> For a full working example which uses Hibernate+JPA+Spring+ES+Byte array  
> converters you can read this article serieshttp://deepintojee.wordpress.com/2012/01/20/add-search-features-to-yo...
> 
> Hope this helps.
> 
> 2012/2/2 Dennis [gear...@gmail.com](mailto:gear...@gmail.com)
> 
> > Sorry, I'm not that great at java, and now a beginner in elastic  
> > search. From what I can tell, ES is just what I need for a project.
> 
> > So, I'd like to make a facade class that has the usual CRUD-and-Find/  
> > Search methods. it will keep the ES and DB in sync, transparent to the  
> > facade class's client.
> 
> > I'd like to have both JSON and Java Entities for IO to the facade  
> > class.
> 
> > Just for clarification purposes, there's no built in functionality in  
> > the Java API to take a java object/entity and index it, right? Nor  
> > Lists and other collections? ES itself takes all JSON, right? So I  
> > have to have a Jackson inteface layer between the Facade class's  
> > private ES client attribute and any Java manipulation, right?
> 
> > Normally, for those on this list who might know, what does JPA/  
> > Hibernate return for a collection?
> 
> --  
> Cordialement/Regards,
> 
> Louis GUEYE  
> linkedin [http://fr.linkedin.com/in/louisgueye](http://fr.linkedin.com/in/louisgueye) |  
> blog[http://deepintojee.wordpress.com/](http://deepintojee.wordpress.com/)|  
> twitter [http://twitter.com/#!/lgueye](http://twitter.com/#%21/lgueye)

---

<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, 3:40am UTC](https://discuss.elastic.co/t/java-entities-in-and-out-and-collection-types/6571/4 "2017-07-06T03:40:43Z")

</div>


