application using jruby accessing remote solr instance.

19 views
Skip to first unread message

tonymi

unread,
Apr 17, 2009, 6:26:01 PM4/17/09
to rsolr
Hi Matt,
Excellent work.

I have an application running using jruby that needs to connect to a
remote solr instance. Looks like the HttpClient interface has a
dependency on 'curb' which has 'C' extensions so wont work with
jruby . Is there a way to make this work using a java HttpClient
library or does the parsing require 'curb'?
I can make jruby talk to solr on the same machine using the :direct
option. Also, I find the jruby :direct option very slow. Can these
'direct' connections be pooled?

Tony

Matt Mitchell

unread,
Apr 17, 2009, 6:42:12 PM4/17/09
to rs...@googlegroups.com
Hi Tony,

The default HTTP adapter is curb. But it should be Net::HTTP - I'll get that change in.

The "curb" alternative is Net::HTTP - this does work with jRuby. I had a pure Java client working at one point and worked great. But the Net::HTTP lib worked just as well so I left it at that.

If you want to use jRuby and HTTP, create an instance of rsolr and then set the http adapter like this:

# running in jruby or standard
rsolr = RSolr.connect(:http)
rsolr.adapter.connector.adapter_name = :net_http

Then when you actually send a solr request, the Net::HTTP stuff is loaded (lazily) and you should be set.

The direct option is slow to start up. Once it is started though, it performs really well. For example in a Rails app I'm working on, I create an instance of RSolr using the direct connection + jruby. The instance is created in the environment file (only once). When a request is made though, the connection is "persistent" and requests are quick.

How are you using the direct handler?

Thanks for checking it out!

Matt

tonymi

unread,
Apr 18, 2009, 5:30:27 AM4/18/09
to rsolr
Hi Matt,
jruby works with the :net_http setting you provided.
The :direct option was slow because I was creating a new direct
connection for every request.

I am also using the rsolr-ext lib and it works great. You may want to
create a link to the rsolr-ext on the rsolr home page.
Thanks for the quick response.

Tony

On Apr 17, 6:42 pm, Matt Mitchell <goodie...@gmail.com> wrote:
> Hi Tony,
>
> The default HTTP adapter is curb. But it should be Net::HTTP - I'll get that
> change in.
>
> The "curb" alternative is Net::HTTP - this does work with jRuby. I had a
> pure Java client working at one point and worked great. But the Net::HTTP
> lib worked just as well so I left it at that.
>
> If you want to use jRuby and HTTP, create an instance of rsolr and then set
> the http adapter like this:
>
> # running in jruby or standard
> rsolr = RSolr.connect(:http)
> rsolr.adapter.connector.adapter_name = :net_http
>
> Then when you actually send a solr request, the Net::HTTP stuff is loaded
> (lazily) and you should be set.
>
> The direct option is slow to start up. Once it is started though, it
> performs really well. For example in a Rails app I'm working on, I create an
> instance of RSolr using the direct connection + jruby. The instance is
> created in the environment file (only once). When a request is made though,
> the connection is "persistent" and requests are quick.
>
> How are you using the direct handler?
>
> Thanks for checking it out!
>
> Matt
>
Reply all
Reply to author
Forward
0 new messages