vendredi 12 janvier 2018

sunpspot solr + rails: undefined methodprepare' for class Sunspot::Indexer'

I am new solr and trying to setup the dev environment of a rails application.

I am have already installed Java-7 and solr on ubuntu machine but when I try to start solr I get the below error

vagrant@precise64:~/myapp/scams$ rake sunspot:solr:start rake aborted! NameError: undefined methodprepare' for class Sunspot::Indexer' /home/vagrant/myapp/scams/config/initializers/sunspot_id.rb:2:inblock in ' /home/vagrant/myapp/scams/config/initializers/sunspot_id.rb:1:in module_eval' /home/vagrant/myapp/scams/config/initializers/sunspot_id.rb:1:in' /home/vagrant/.rvm/gems/ruby-2.2.7/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:268:i`

sunspot.yml:

 development:
     solr:
       hostname: localhost
       port: 8982
       log_level: INFO
       #path: /solr/development
       solr_home: solr
       # pid_dir: defaults to 'app/solr/pids/development'
       # bind_address: defaults to '0.0.0.0' which binds to every interface
    disabled: false # note that this is not indented within solr
   test:
    solr:
      hostname: localhost
      port: 8981
      log_level: WARNING

Sunpot_id.rb:

Sunspot::Indexer.module_eval do
  alias :old_prepare :prepare

  def prepare(model)
    document = old_prepare(model)
    if model.class == Resource
      document.fields_by_name(:resource_id_ss).first.value = document.fields_by_name(:id).first.value
      if !document.fields_by_name(:filename).blank? and !document.fields_by_name(:filename).first.blank?
        document.fields_by_name(:id).first.value = document.fields_by_name(:filename).first.value
      end
    end
    document
  end

It has been more than two days with the issue. Someone please help me with this.

Aucun commentaire:

Enregistrer un commentaire