Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sunspot with jruby

Hi can sunspot be used with jruby, also here is my app details

jruby-1.6.1
rails 3.0.7 

when i install all the gems and run rake sunspot:solr:start it gives me the following error 

Gem::LoadError: Could not find RubyGem sunspot (>= 0)

  report_activate_error at /Users/dpatel/.rvm/rubies/jruby-1.6.1/lib/ruby/site_ruby/1.8/rubygems.rb:861
               activate at /Users/dpatel/.rvm/rubies/jruby-1.6.1/lib/ruby/site_ruby/1.8/rubygems.rb:255
                    gem at /Users/dpatel/.rvm/rubies/jruby-1.6.1/lib/ruby/site_ruby/1.8/rubygems.rb:1215
                 (root) at /Users/dpatel/.rvm/gems/jruby-1.6.1@solr/bin/sunspot-solr:18

However when I run rake sunspot:solr:run, it works fine.

Also, when i search using Model.search, it works fine, but I when I fire up solr webapp on the browser and search something, it does not work.

Can anyone tell me what is happening, new to sunspot.

-Thanks

like image 234
dhaval2025 Avatar asked Jul 25 '26 19:07

dhaval2025


2 Answers

Hi i kinda figured it out, i am on jruby and fork is not allowed on jruby, and rake sunspot:solr:start tries to fork and thrown out an error but rake sunspot:solr:run starts solr in the foreground and works fine, a little painful but all is well :-)

-D

like image 121
dhaval2025 Avatar answered Jul 28 '26 11:07

dhaval2025


You already figured out the forking issue, so if you want to stay in a single shell for development and testing I found these aliases to be particularly useful for running sunspot in a particular rails environment and then finding and killing that process when I am done:

If you keep the default ports:

alias sunspot_run_test="RAILS_ENV=test sunspot-solr run &"
alias sunspot_kill_test="fuser -n tcp 8982 -k"
alias sunspot_run_dev="RAILS_ENV=test sunspot-solr run &"
alias sunspot_kill_dev="fuser -n tcp 8982 -k

If you change ports you will need to change the auto-generated sunspot.yml or put a sunspot.rb in config>initializers and you can add a -p{$port_num} before the & on the run aliases and change the explicit port numbers to {$port_num} for the kill aliases.

As Vlad mentioned, it's hard to know what's going on with in the browser from your explanation. One thing that can catch you if you are new to sunspot is that you need to have an instance running in dev environment (use the sunspot_run_dev alias) before you try to CRUD anything in your database or you will get an connection refused error.

See bash aliases not recognized by a bash function: sunspot_rails, jruby, rspec for some more troubleshooting with functions to wrap commands that require sunspot.

like image 30
C Del Avatar answered Jul 28 '26 12:07

C Del



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!