Indexing Objects with Java

Hi,

I'm testing Elasticsearch as replacement to our current MongoDB
implementation for storing and searching information.
The application I'm working on has a Django frontend that query the
information, and an engine built with Java. I have almost no experience
working with Java, so I'm having some trouble to figure out how to store
objects that have other objects as attributes.

As you can see in here (1), I'm creating an user object with the
information I need to store, and then I set this user as a content
attribute.
I know I'm doing something wrong because the document gets stored without
the user information. In the log files, the user entry is sent as string
('user': {'type': 'string'}) .

I thought to use a Map to store those fields I need from the user object,
but I don't know if that is the Java way or even a nice way to doit.

Could someone throw me a line here?

Thanks,
Martin

Links:
1- https://gist.github.com/1438221

--
Martín

http://www.kyheo.com.ar
GTalk: marrese@gmail.com

When you build the json, you need to have another "startObject" and
"endObject" to wrap the json you construct (startObject == {, endObject ==
}).

On Tue, Dec 6, 2011 at 3:45 PM, marrese@gmail.com marrese@gmail.com wrote:

Hi,

I'm testing Elasticsearch as replacement to our current MongoDB
implementation for storing and searching information.
The application I'm working on has a Django frontend that query the
information, and an engine built with Java. I have almost no experience
working with Java, so I'm having some trouble to figure out how to store
objects that have other objects as attributes.

As you can see in here (1), I'm creating an user object with the
information I need to store, and then I set this user as a content
attribute.
I know I'm doing something wrong because the document gets stored without
the user information. In the log files, the user entry is sent as string
('user': {'type': 'string'}) .

I thought to use a Map to store those fields I need from the user object,
but I don't know if that is the Java way or even a nice way to doit.

Could someone throw me a line here?

Thanks,
Martin

Links:
1- https://gist.github.com/1438221

--
Martín

http://www.kyheo.com.ar
GTalk: marrese@gmail.com

Shay,

Thanks for the response, but sadly I didn't got it working.

I don't understand where should I put the extra startObject and endObjects
calls. The user object is already created with startObject and endObject.
If I call them when adding the user object to the content one I got an
exception.

Could you please be a little more specific, and perhaps with the two or
three lines that will do what you said ? ... I'm really new with Java and
I'm still struggling with language issues :S

Thanks.
Martin

On Tue, Dec 6, 2011 at 17:37, Shay Banon kimchy@gmail.com wrote:

When you build the json, you need to have another "startObject" and
"endObject" to wrap the json you construct (startObject == {, endObject ==
}).

On Tue, Dec 6, 2011 at 3:45 PM, marrese@gmail.com marrese@gmail.comwrote:

Hi,

I'm testing Elasticsearch as replacement to our current MongoDB
implementation for storing and searching information.
The application I'm working on has a Django frontend that query the
information, and an engine built with Java. I have almost no experience
working with Java, so I'm having some trouble to figure out how to store
objects that have other objects as attributes.

As you can see in here (1), I'm creating an user object with the
information I need to store, and then I set this user as a content
attribute.
I know I'm doing something wrong because the document gets stored without
the user information. In the log files, the user entry is sent as string
('user': {'type': 'string'}) .

I thought to use a Map to store those fields I need from the user object,
but I don't know if that is the Java way or even a nice way to doit.

Could someone throw me a line here?

Thanks,
Martin

Links:
1- https://gist.github.com/1438221

--
Martín

http://www.kyheo.com.ar
GTalk: marrese@gmail.com

--
Martín

http://www.kyheo.com.ar
GTalk: marrese@gmail.com

Sorry, I got confused by your code a bit. I commented with something that
should work (the user aspect). I also added setId just so you can more
easily fetch it by id (if you test it), nad actionGet() at the end of the
index to wait for the index operation to finish (execute is async).

On Wed, Dec 7, 2011 at 5:43 PM, marrese@gmail.com marrese@gmail.com wrote:

Shay,

Thanks for the response, but sadly I didn't got it working.

I don't understand where should I put the extra startObject and endObjects
calls. The user object is already created with startObject and endObject.
If I call them when adding the user object to the content one I got an
exception.

Could you please be a little more specific, and perhaps with the two or
three lines that will do what you said ? ... I'm really new with Java and
I'm still struggling with language issues :S

Thanks.
Martin

On Tue, Dec 6, 2011 at 17:37, Shay Banon kimchy@gmail.com wrote:

When you build the json, you need to have another "startObject" and
"endObject" to wrap the json you construct (startObject == {, endObject ==
}).

On Tue, Dec 6, 2011 at 3:45 PM, marrese@gmail.com marrese@gmail.comwrote:

Hi,

I'm testing Elasticsearch as replacement to our current MongoDB
implementation for storing and searching information.
The application I'm working on has a Django frontend that query the
information, and an engine built with Java. I have almost no experience
working with Java, so I'm having some trouble to figure out how to store
objects that have other objects as attributes.

As you can see in here (1), I'm creating an user object with the
information I need to store, and then I set this user as a content
attribute.
I know I'm doing something wrong because the document gets stored
without the user information. In the log files, the user entry is sent as
string ('user': {'type': 'string'}) .

I thought to use a Map to store those fields I need from the user
object, but I don't know if that is the Java way or even a nice way to doit.

Could someone throw me a line here?

Thanks,
Martin

Links:
1- https://gist.github.com/1438221

--
Martín

http://www.kyheo.com.ar
GTalk: marrese@gmail.com

--
Martín

http://www.kyheo.com.ar
GTalk: marrese@gmail.com

Shay,

Thanks, I'm looking it right know and will try it in a bit ...

Martin

On Wed, Dec 7, 2011 at 12:54, Shay Banon kimchy@gmail.com wrote:

Sorry, I got confused by your code a bit. I commented with something that
should work (the user aspect). I also added setId just so you can more
easily fetch it by id (if you test it), nad actionGet() at the end of the
index to wait for the index operation to finish (execute is async).

On Wed, Dec 7, 2011 at 5:43 PM, marrese@gmail.com marrese@gmail.comwrote:

Shay,

Thanks for the response, but sadly I didn't got it working.

I don't understand where should I put the extra startObject and
endObjects calls. The user object is already created with startObject and
endObject. If I call them when adding the user object to the content one I
got an exception.

Could you please be a little more specific, and perhaps with the two or
three lines that will do what you said ? ... I'm really new with Java and
I'm still struggling with language issues :S

Thanks.
Martin

On Tue, Dec 6, 2011 at 17:37, Shay Banon kimchy@gmail.com wrote:

When you build the json, you need to have another "startObject" and
"endObject" to wrap the json you construct (startObject == {, endObject ==
}).

On Tue, Dec 6, 2011 at 3:45 PM, marrese@gmail.com marrese@gmail.comwrote:

Hi,

I'm testing Elasticsearch as replacement to our current MongoDB
implementation for storing and searching information.
The application I'm working on has a Django frontend that query the
information, and an engine built with Java. I have almost no experience
working with Java, so I'm having some trouble to figure out how to store
objects that have other objects as attributes.

As you can see in here (1), I'm creating an user object with the
information I need to store, and then I set this user as a content
attribute.
I know I'm doing something wrong because the document gets stored
without the user information. In the log files, the user entry is sent as
string ('user': {'type': 'string'}) .

I thought to use a Map to store those fields I need from the user
object, but I don't know if that is the Java way or even a nice way to doit.

Could someone throw me a line here?

Thanks,
Martin

Links:
1- https://gist.github.com/1438221

--
Martín

http://www.kyheo.com.ar
GTalk: marrese@gmail.com

--
Martín

http://www.kyheo.com.ar
GTalk: marrese@gmail.com

--
Martín

http://www.kyheo.com.ar
GTalk: marrese@gmail.com

Martin,

Hope you bit the bullet sometime for Java but you can probably avoid using
it - at least to start/evaluate. I believe the ElastiSearc Head plugin only
uses JavaScript to interact with ES. You might be able to do JS call
replacements under Django.This might not be your long term solution but
could let you see what ES can do. I also believe there are some JS clients
for ES out there - though not sure if any are current/blessed.
--Mike

On Wed, Dec 7, 2011 at 10:43 AM, marrese@gmail.com marrese@gmail.comwrote:

Shay,

Thanks for the response, but sadly I didn't got it working.

I don't understand where should I put the extra startObject and endObjects
calls. The user object is already created with startObject and endObject.
If I call them when adding the user object to the content one I got an
exception.

Could you please be a little more specific, and perhaps with the two or
three lines that will do what you said ? ... I'm really new with Java and
I'm still struggling with language issues :S

Thanks.
Martin

On Tue, Dec 6, 2011 at 17:37, Shay Banon kimchy@gmail.com wrote:

When you build the json, you need to have another "startObject" and
"endObject" to wrap the json you construct (startObject == {, endObject ==
}).

On Tue, Dec 6, 2011 at 3:45 PM, marrese@gmail.com marrese@gmail.comwrote:

Hi,

I'm testing Elasticsearch as replacement to our current MongoDB
implementation for storing and searching information.
The application I'm working on has a Django frontend that query the
information, and an engine built with Java. I have almost no experience
working with Java, so I'm having some trouble to figure out how to store
objects that have other objects as attributes.

As you can see in here (1), I'm creating an user object with the
information I need to store, and then I set this user as a content
attribute.
I know I'm doing something wrong because the document gets stored
without the user information. In the log files, the user entry is sent as
string ('user': {'type': 'string'}) .

I thought to use a Map to store those fields I need from the user
object, but I don't know if that is the Java way or even a nice way to doit.

Could someone throw me a line here?

Thanks,
Martin

Links:
1- https://gist.github.com/1438221

--
Martín

http://www.kyheo.com.ar
GTalk: marrese@gmail.com

--
Martín

http://www.kyheo.com.ar
GTalk: marrese@gmail.com

Mike,

I got it working with what Shay said, so I can test ES using the same app
we have right know, just with another storage.

Thank you both,
Martin

On Wed, Dec 7, 2011 at 13:05, Michael Sick
michael.sick@serenesoftware.comwrote:

Martin,

Hope you bit the bullet sometime for Java but you can probably avoid using
it - at least to start/evaluate. I believe the ElastiSearc Head plugin only
uses JavaScript to interact with ES. You might be able to do JS call
replacements under Django.This might not be your long term solution but
could let you see what ES can do. I also believe there are some JS clients
for ES out there - though not sure if any are current/blessed.
--Mike

On Wed, Dec 7, 2011 at 10:43 AM, marrese@gmail.com marrese@gmail.comwrote:

Shay,

Thanks for the response, but sadly I didn't got it working.

I don't understand where should I put the extra startObject and
endObjects calls. The user object is already created with startObject and
endObject. If I call them when adding the user object to the content one I
got an exception.

Could you please be a little more specific, and perhaps with the two or
three lines that will do what you said ? ... I'm really new with Java and
I'm still struggling with language issues :S

Thanks.
Martin

On Tue, Dec 6, 2011 at 17:37, Shay Banon kimchy@gmail.com wrote:

When you build the json, you need to have another "startObject" and
"endObject" to wrap the json you construct (startObject == {, endObject ==
}).

On Tue, Dec 6, 2011 at 3:45 PM, marrese@gmail.com marrese@gmail.comwrote:

Hi,

I'm testing Elasticsearch as replacement to our current MongoDB
implementation for storing and searching information.
The application I'm working on has a Django frontend that query the
information, and an engine built with Java. I have almost no experience
working with Java, so I'm having some trouble to figure out how to store
objects that have other objects as attributes.

As you can see in here (1), I'm creating an user object with the
information I need to store, and then I set this user as a content
attribute.
I know I'm doing something wrong because the document gets stored
without the user information. In the log files, the user entry is sent as
string ('user': {'type': 'string'}) .

I thought to use a Map to store those fields I need from the user
object, but I don't know if that is the Java way or even a nice way to doit.

Could someone throw me a line here?

Thanks,
Martin

Links:
1- https://gist.github.com/1438221

--
Martín

http://www.kyheo.com.ar
GTalk: marrese@gmail.com

--
Martín

http://www.kyheo.com.ar
GTalk: marrese@gmail.com

--
Martín

http://www.kyheo.com.ar
GTalk: marrese@gmail.com