Question

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

Was it helpful?

Solution

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

OTHER TIPS

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.

For rake issue:

gem install sunspot -v 1.2.rc4

For 'does not work in browser': what do you mean it does not work?

  • if no result is returned:

You can debug it by comparing Solr requests made by you manually on script/console and the ones made by the server. By default, the sunspot gem logs requests in 'logs/sunspot-solr-development.log'

  • error (which?)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top