Integration framework for Jersey app?

Hi all,

I have a simple RESTful application (Jersey, Guice, MyBATIS) and would like
to add search support using ES (previously we've used SOLR).

My app is all Guice wired, and I was thinking I would do a method
interceptor for the mutator methods, and then either maintain the index or
fire a RabbitMQ message and use the RMQ river (probably I would do the
former).

It seems to me though, that what I am trying to do is so common there might
be a framework already for this?

I have googled a bit, but found nothing specific. Am I missing something?
(I am a newbie in ES)

Ideally I would expect I can have something like this with a single
annotation to maintain the index, which would be handled by some method
interceptor:

@Singleton
@Path("node")
public class NodeResource implements NodeService {

private final NodeMapper nodeMapper;

@Inject
public NodeResource(NodeMapper nodeMapper) {
this.nodeMapper = nodeMapper;
}

@PUT
@SOME_ANNOTATION_HERE
@Override
public void update(Node entity) {
WithMyBatis.update(nodeMapper, entity);
}
...
}

Any suggestions from those with experience would be greatly appreciated (we
can tolerate short lived inconsistency, and the index is going to be small).

Cheers,
Tim

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Hi Tim,
So, not sure this is quite the answer you're looking for, but I also
have a java webapp with an elasticsearch component, and I've found it
useful to fire up my elasticsearch nodes in my webapp itself, I use
https://github.com/elasticsearch/elasticsearch-transport-wares to do this.
Then, in web.xml I just:

node
org.elasticsearch.wares.NodeServlet
1

I have one node per instance of my web application; I actually prefer this,
but this route does remove the ability to separate your elasticsearch nodes
from your web application (the plus side is you don't have to manage both).

Then, when I want to use it from a controller or similar, I just inject a
(spring configured, in my case) TransportClient. Pretty sure you could
guice configure a TransportClient relatively easily, it just needs a few
basic things like hostname/port/clusterName.

Hope this helps!

--paul

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Thanks Paul,

That is not too disimilar to what I have done this afternoon, but I went
for an embedded node started with Guice, so then I Guice injects a regular
client in the code.

How do you manage your index please? Are you just scattering calls to
TransportClient all around the code, or have you done some kind of cross
cutting approach (like method interceptors)?

Cheers,
Tim

On Thu, Feb 28, 2013 at 7:40 PM, Paul Sanwald paul@redowlanalytics.comwrote:

Hi Tim,
So, not sure this is quite the answer you're looking for, but I also
have a java webapp with an elasticsearch component, and I've found it
useful to fire up my elasticsearch nodes in my webapp itself, I use
GitHub - elastic/elasticsearch-transport-wares: Servlet transport for Elasticsearch to do
this. Then, in web.xml I just:

node
org.elasticsearch.wares.NodeServlet
1

I have one node per instance of my web application; I actually prefer
this, but this route does remove the ability to separate your elasticsearch
nodes from your web application (the plus side is you don't have to manage
both).

Then, when I want to use it from a controller or similar, I just inject a
(spring configured, in my case) TransportClient. Pretty sure you could
guice configure a TransportClient relatively easily, it just needs a few
basic things like hostname/port/clusterName.

Hope this helps!

--paul

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Hi Tim,
probably a bit old school, but I have a searchIndexDAO class that has
the client injected, and my jersey resources all just inject the DAO and
use that, instead of a TransportClient directly. So really my
TransportClient is only ever injected in one place in the code. I did this
for mostly for reuse reasons, although a little of the old Separation Of
Concerns doesn't kill me here I suppose :).

my index is managed on AWS, I use the ec2 discovery and s3 gateway, and use
a special security group for node discovery.

--paul

On Thursday, February 28, 2013 2:09:30 PM UTC-5, Tim Robertson wrote:

Thanks Paul,

That is not too disimilar to what I have done this afternoon, but I went
for an embedded node started with Guice, so then I Guice injects a regular
client in the code.

How do you manage your index please? Are you just scattering calls to
TransportClient all around the code, or have you done some kind of cross
cutting approach (like method interceptors)?

Cheers,
Tim

On Thu, Feb 28, 2013 at 7:40 PM, Paul Sanwald <pa...@redowlanalytics.com<javascript:>

wrote:

Hi Tim,
So, not sure this is quite the answer you're looking for, but I also
have a java webapp with an elasticsearch component, and I've found it
useful to fire up my elasticsearch nodes in my webapp itself, I use
GitHub - elastic/elasticsearch-transport-wares: Servlet transport for Elasticsearch to do
this. Then, in web.xml I just:

node
org.elasticsearch.wares.NodeServlet
1

I have one node per instance of my web application; I actually prefer
this, but this route does remove the ability to separate your elasticsearch
nodes from your web application (the plus side is you don't have to manage
both).

Then, when I want to use it from a controller or similar, I just inject a
(spring configured, in my case) TransportClient. Pretty sure you could
guice configure a TransportClient relatively easily, it just needs a few
basic things like hostname/port/clusterName.

Hope this helps!

--paul

--
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 elasticsearc...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Thanks Paul

On Thu, Feb 28, 2013 at 8:30 PM, Paul Sanwald paul@redowlanalytics.comwrote:

Hi Tim,
probably a bit old school, but I have a searchIndexDAO class that has
the client injected, and my jersey resources all just inject the DAO and
use that, instead of a TransportClient directly. So really my
TransportClient is only ever injected in one place in the code. I did this
for mostly for reuse reasons, although a little of the old Separation Of
Concerns doesn't kill me here I suppose :).

my index is managed on AWS, I use the ec2 discovery and s3 gateway, and
use a special security group for node discovery.

--paul

On Thursday, February 28, 2013 2:09:30 PM UTC-5, Tim Robertson wrote:

Thanks Paul,

That is not too disimilar to what I have done this afternoon, but I went
for an embedded node started with Guice, so then I Guice injects a regular
client in the code.

How do you manage your index please? Are you just scattering calls to
TransportClient all around the code, or have you done some kind of cross
cutting approach (like method interceptors)?

Cheers,
Tim

On Thu, Feb 28, 2013 at 7:40 PM, Paul Sanwald pa...@redowlanalytics.comwrote:

Hi Tim,
So, not sure this is quite the answer you're looking for, but I also
have a java webapp with an elasticsearch component, and I've found it
useful to fire up my elasticsearch nodes in my webapp itself, I use
https://github.com/**elasticsearch/elasticsearch-**transport-wareshttps://github.com/elasticsearch/elasticsearch-transport-waresto do this. Then, in web.xml I just:

node</servlet-**name>
org.elasticsearch.wares.
NodeServlet
1</load-on-**startup>

I have one node per instance of my web application; I actually prefer
this, but this route does remove the ability to separate your elasticsearch
nodes from your web application (the plus side is you don't have to manage
both).

Then, when I want to use it from a controller or similar, I just inject
a (spring configured, in my case) TransportClient. Pretty sure you could
guice configure a TransportClient relatively easily, it just needs a few
basic things like hostname/port/clusterName.

Hope this helps!

--paul

--
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 elasticsearc...@**googlegroups.com.

For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.