Sunspot_Rails Rake Aborted at Reindex Launch

I cannot index my search database with sunspot_rails. I get the following error:

Running a sunspot: rake rake interrupted! undefined local variable or 'Counter' method

I get the following result after running rake sunspot: reindex. I am new to Rails. I want to add sunspot_rails to my project in order to add search functions (with the hope of deploying the project with Heroku).

I use Rails 3. I followed the instructions below: https://github.com/outoftime/sunspot/blob/master/sunspot_rails/README.rdoc . My other attempts to diagnose the problem included:

  • setting a sunspot in addition to sunspot_rails.
  • I ended up with sunspot_rails v. 1.2.0 and 1.2.1, so I deleted 1.2.1 because I have sunspot_rails 1.2.0.
  • installed nokogiri gem, which, as I understand it, is a dependency on sunspot_rails.
  • libxml2 is installed separately, following the instructions here to install nokogiri: http://www.engineyard.com/blog/2010/getting-started-with-nokogiri/

    ** Call Sun Spot: reindex (first_time) ** Call Wednesday (first_time) ** Run Wednesday ** Run Sun Spot: raid rake interrupted! undefined local variable or counter' for [removed pound]<Class:0x10359aef8> /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/base.rb:1008:inmethod_missing '/Library/Ruby/Gems/1.8/gems/sunspot_rails-1.2.0/lib/sunspot/rails/searchable.rb:235:in solr_index' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/relation/batches.rb:71:infind_in_batches' / Library / Ruby / Gems / 1.8 / gems / activerecord-3.0.3 / lib / active_record / base.rb: 440: in __send__' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/base.rb:440:infind_in_batches' /Library/Ruby/Gems/1.8/gems/sunspot_rails-1.2.0/lib/sunspot/rails/searchable.rb:234:in solr_index' /Library/Ruby/Gems/1.8/gems/sunspot_rails-1.2.0/lib/sunspot/rails/searchable.rb:184:insolr_reindex '/Library/Ruby/Gems/1.8/gems/sunspot_rails-1.2.0/lib/sunspot/rails/tasks.rb:57/Library/Ruby/Gems/1.8/gems/sunspot_rails-1.2.0/lib/sunspot/ rails / tasks.rb: 56: in each' /Library/Ruby/Gems/1.8/gems/sunspot_rails-1.2.0/lib/sunspot/rails/tasks.rb:56 /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:incall '/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb: 636: inexecute' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:ineach '/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in execute' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:ininvoke_with_call_chain' / System / Library / Frameworks / Ruby.framework / Versions / 1.8 / usr / lib / ruby /1.8/monitor.rb:242:in synchronize' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:ininvoke_with_call_chain '/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb{83: in invoke' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:ininvoke_task' /Library/Ruby/Gems/1.8/gems /rake-0.8.7/lib/rake.rb:2029:in top_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:ineach '/ Library / Ruby / Gems / 1.8 / gems / rake- 0.8.7 / l ib / rake.rb: 2029: in top_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:instandard_exception_handling' / Library / Ruby / Gems / 1.8 / gems / rake-0.8.7 / lib / rake.rb: 2023: in top_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:inrun '/ Library / Ruby / Gems / 1.8 / gems / rake-0.8.7 / lib / rake.rb: 2068: in standard_exception_handling' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:inrun '/Library/Ruby/Gems/1.8/gems/rake-0.8.7/bin/rake:31/usr/bin/rake: 19: in `load' / usr / bin / rake: 19

This is what I have in the class I would like to find:

  searchable do
    text :fname
    text :mname
    text :lname, :default_boost => 2   end

!

+3
3

sunspot_rails-1.2.0/lib/sunspot/rails/searchable.rb: 235. .

:

    def solr_index(opts={})
      options = {
        :batch_size => 500,
        :batch_commit => true,
        :include => self.sunspot_options[:include],
        :first_id => 0
      }.merge(opts)

      if options[:batch_size]
        counter = 1 #Add the variable
        find_in_batches(:include => options[:include], :batch_size => options[:batch_size]) do |records|
          solr_benchmark options[:batch_size], counter do
            Sunspot.index(records)
          end
          Sunspot.commit if options[:batch_commit]
          counter += 1 # Increase the variable
        end
        Sunspot.commit unless options[:batch_commit]
      else
        Sunspot.index!(all(:include => options[:include]))
      end
    end

find_in_batches find_in_batches. . ~

+2

, Sunspot 1.2.1

+1

, user34.

Just install Sunspot for Rails 3.0.1 on Ubuntu 10.4. After the first encounter with connection problems with reindexing (Ubuntu users should be sure that they are working on Javascript, it seems to be sudo apt-get install default-jdk), then I encountered the same problem as Walter with the "counter".

Is this a new Sunspot issue? Interesting?

In any case, you sent your answer just a couple of hours before I needed it .. and, as far as I can tell, I look good now.

Thank you both .. (and ALWAYS be wary of 5-minute installation requests :))

0
source

Source: https://habr.com/ru/post/1791744/


All Articles