Issues while re-indexing #216

Closed
Ratzzak opened this Issue Apr 20, 2012 · 12 comments

Projects

None yet

6 participants

@Ratzzak
Ratzzak commented Apr 20, 2012

I have configured solr using sunspot on my rails application which uses mongodb and when I run the reindex command rake sunspot:reindex it gives me this error:

rake aborted!
undefined method `indexing' for #<LightConfig::Configuration:0xb5472ec>

This is my model

class Article
  include Mongoid::Document
  field :name
  field :content


  include Sunspot::Mongoid
  searchable do
    text :name, :content
  end
end
@alindeman
Member

Can you post the output when you run rake with --trace?

@Ratzzak
Ratzzak commented Apr 20, 2012

@alindeman

Thanx for quick reply. Here is the trace file

** Invoke sunspot:reindex (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute sunspot:reindex
Re-indexing Article
rake aborted!
undefined method indexing' for #<LightConfig::Configuration:0xb040c44> /home/rahul/.rvm/gems/ruby-1.9.2-p290/bundler/gems/sunspot_mongoid-d269b497de00/lib/sunspot/mongoid.rb:43:insolr_index'
/home/rahul/.rvm/gems/ruby-1.9.2-p290/gems/sunspot_rails-1.3.1/lib/sunspot/rails/searchable.rb:198:in solr_reindex' /home/rahul/.rvm/gems/ruby-1.9.2-p290/bundler/gems/sunspot_mongoid-d269b497de00/tasks/sunspot_mongoid.rake:44:inblock (3 levels) in <top (required)>'
/home/rahul/.rvm/gems/ruby-1.9.2-p290/bundler/gems/sunspot_mongoid-d269b497de00/tasks/sunspot_mongoid.rake:42:in each' /home/rahul/.rvm/gems/ruby-1.9.2-p290/bundler/gems/sunspot_mongoid-d269b497de00/tasks/sunspot_mongoid.rake:42:inblock (2 levels) in <top (required)>'
/home/rahul/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:205:in call' /home/rahul/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:205:inblock in execute'
/home/rahul/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:200:in each' /home/rahul/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:200:inexecute'
/home/rahul/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:158:in block in invoke_with_call_chain' /home/rahul/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:inmon_synchronize'
/home/rahul/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:151:in invoke_with_call_chain' /home/rahul/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:144:ininvoke'
/home/rahul/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:116:in invoke_task' /home/rahul/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:94:inblock (2 levels) in top_level'
/home/rahul/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:94:in each' /home/rahul/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:94:inblock in top_level'
/home/rahul/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:133:in standard_exception_handling' /home/rahul/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:88:intop_level'
/home/rahul/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:66:in block in run' /home/rahul/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:133:instandard_exception_handling'
/home/rahul/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:63:in run' /home/rahul/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/bin/rake:33:in<top (required)>'
/home/rahul/.rvm/gems/ruby-1.9.2-p290/bin/rake:19:in load' /home/rahul/.rvm/gems/ruby-1.9.2-p290/bin/rake:19:in

'
Tasks: TOP => sunspot:reindex

@alindeman
Member

It looks like you're using a git version of sunspot_mongoid .. maybe a custom version? Can you post the line from your Gemfile that brings it in?

@Ratzzak
Ratzzak commented Apr 20, 2012

@alindeman

This is the sunspot_mongoid gem I am using
gem 'sunspot_mongoid', :git => 'https://github.com/sujal/sunspot_mongoid.git'

When I normally use gem 'sunspot_mongoid', I get the following error while reindexing
undefined method 'find_in_batches' for Article:Class
I was suggested to use that gem to solve this issue.

@alindeman
Member

Ah, default_batch_size was introduced in the master branch of Sunspot. It's not available in 1.3.x.

You might try upgrading sunspot (or sunspot_rails) to ~>2.0.0.pre.

https://github.com/sujal/sunspot_mongoid/blob/master/lib/sunspot/mongoid.rb#L43

@marbemac

That worked for me, thanks!

@alindeman alindeman closed this Apr 25, 2012
@Ratzzak
Ratzzak commented Apr 26, 2012

@alindeman Still didnt work for me
@marbemac Could you please let me know what are the exact gems u were using?

@AaronH
AaronH commented Apr 27, 2012

Yeah, I'm still having this issue using a forked version of sunspot_mongoid as well. I'm looking to track down a solution, bout wanted to make sure @Ratzzak knew he wasn't alone.

@AaronH
AaronH commented Apr 27, 2012

@Ratzzak It looks like the problem was introduced in these 3 commits from March 26/27. I tried simply replacing the references to Sunspot.config.indexing.default_batch_size with a number, but there are other problems introduced with version skew, etc. since then. I don't have time to sort it out in my own fork at this time, but if you change your gem file as follows it should work.

gem 'sunspot_mongoid', git: 'git://github.com/sujal/sunspot_mongoid.git', ref: '5d379c6cdde37851beac5547742fc61b1653a6ae'
@AaronH
AaronH commented Apr 27, 2012

Actually, I was able to find the problem (a simple typo) in https://github.com/sujal/sunspot_mongoid. My fork at https://github.com/AaronH/sunspot_mongoid has those problems fixed and now works as expected. I'll be submitting my pull request.

@wyh770406

thanks ,this solved my problems

@nengine
nengine commented Sep 22, 2012

Hi, I was able to reindex, however getting "NameError: uninitialized constant Sunspot::Mongoid::DataAccessor::BSON"

search = Person.search do
      fulltext 'apple'
    end

    search.results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment