Java entities in and out and collection types


(Dennis) #1

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?


(louis gueye) #2

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

Hope this helps.

2012/2/2 Dennis 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 |
bloghttp://deepintojee.wordpress.com/|
twitter http://twitter.com/#!/lgueye


(Dennis) #3

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 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

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 |
bloghttp://deepintojee.wordpress.com/|
twitter http://twitter.com/#!/lgueye


(system) #4