rake sunspot:solr:reindex不能在带有多个引擎的Rails 4 app中工作

我有多个引擎的rails 4 beta1应用程序。 我在我的主机应用程序中安装了sunspot_rails gem /2.0.0.pre.130115/。 我的大多数模特都住在engine1。 我在其他引擎上使用它们。 安装sunspot_rails后,使用rake sunspot:solr:run sunspot rake sunspot:solr:runcommand/task not found 。 根据文档,我找到了解决方案。 这是链接: https : //github.com/sunspot/sunspot/wiki/Adding-Sunspot-search-to-Rails-in-5-minutes-or-less

在我创建新记录后,Solr在搜索中找到了它。 但是当我重新编制数据索引时,仍然没有通过搜索找到旧记录。 在我看来,reindex没有奏效。 我已经尝试停止并重新启动solr服务器,重启我的电脑几次但没有运气。 任何的想法?

如果您需要更多信息,请告诉我。

这是我的gem:

 Gems included by the bundle: * actionmailer (4.0.0.beta1) * actionpack (4.0.0.beta1) * activemodel (4.0.0.beta1) * activerecord (4.0.0.beta1) * activerecord-deprecated_finders (0.0.3) * activesupport (4.0.0.beta1) * admin (0.0.1) * arel (4.0.0.beta2) * atomic (1.1.7) * bcrypt-ruby (3.0.1) * builder (3.1.4) * bundler (1.3.2) * coffee-rails (4.0.0.beta1) * coffee-script (2.2.0) * coffee-script-source (1.6.2) * core (0.0.1) * erubis (2.7.0) * execjs (1.4.0) * factory_girl (4.2.0) * factory_girl_rails (4.2.1) * fattr (2.2.1) * frontend (0.0.1) * highline (1.6.18) * hike (1.2.2) * i18n (0.6.4) * jbuilder (1.0.2) * jquery-rails (2.2.1) * json (1.7.7) * kaminari (0.14.1) * mail (2.5.3) * mime-types (1.22) * minitest (4.7.1) * multi_json (1.7.2) * nokogiri (1.5.9) * options (2.3.0) * pg (0.15.1) * polyglot (0.3.3) * pr_geohash (1.0.0) * progress_bar (1.0.0) * rack (1.5.2) * rack-test (0.6.2) * rails (4.0.0.beta1) * rails-i18n (0.7.3 1fc01d5) * railties (4.0.0.beta1) * rake (10.0.4) * rdoc (3.12.2) * rsolr (1.0.9) * sass (3.2.7) * sass-rails (4.0.0.beta1) * sprockets (2.9.2) * sprockets-rails (2.0.0.rc3) * store_admin (0.0.1) * store_frontend (0.0.1) * sunspot (2.0.0.pre.130115) * sunspot_rails (2.0.0.pre.130115) * sunspot_solr (2.0.0.pre.130115) * thor (0.18.1) * thread_safe (0.1.0) * tilt (1.3.7) * treetop (1.4.12) * tzinfo (0.3.37) * uglifier (2.0.1) 

手动生成的solr任务:

 namespace :sunspot do namespace :solr do desc 'Start the Solr instance' task :start => :environment do case RUBY_PLATFORM when /w(in)?32$/, /java$/ abort("This command is not supported on #{RUBY_PLATFORM}. " + "Use rake sunspot:solr:run to run Solr in the foreground.") end if defined?(Sunspot::Rails::Server) Sunspot::Rails::Server.new.start else Sunspot::Solr::Server.new.start end puts "Successfully started Solr ..." end desc 'Run the Solr instance in the foreground' task :run => :environment do if defined?(Sunspot::Rails::Server) Sunspot::Rails::Server.new.run else Sunspot::Solr::Server.new.run end end desc 'Stop the Solr instance' task :stop => :environment do case RUBY_PLATFORM when /w(in)?32$/, /java$/ abort("This command is not supported on #{RUBY_PLATFORM}. " + "Use rake sunspot:solr:run to run Solr in the foreground.") end if defined?(Sunspot::Rails::Server) Sunspot::Rails::Server.new.stop else Sunspot::Solr::Server.new.stop end puts "Successfully stopped Solr ..." end # for backwards compatibility task :reindex => :"sunspot:reindex" end end 

我的模特:

 # encoding: utf-8 class Product < ActiveRecord::Base ## # Sunspot searchable auto_index: true, auto_remove: true do text :name, boost: 5 text :description, boost: 4 # integer :store_id end end 

最后是solr的schema.xml

                                                  <!-- Valid attributes for fields: name: mandatory - the name for the field type: mandatory - the name of a previously defined type from the  section indexed: true if this field should be indexed (searchable or sortable) stored: true if this field should be retrievable compressed: [false] if this field should be stored using gzip compression (this will only apply if the field type is compressable; among the standard field types, only TextField and StrField are) multiValued: true if this field may contain multiple values per document omitNorms: (expert) set to true to omit the norms associated with this field (this disables length normalization and index-time boosting for the field, and saves some memory). Only full-text fields or fields that need an index-time boost need norms. termVectors: [false] set to true to store the term vector for a given field. When using MoreLikeThis, fields used for similarity should be stored for best performance. termPositions: Store position information with the term vector. This will increase storage costs. termOffsets: Store offset information with the term vector. This will increase storage costs. default: a value that should be used if no value is specified when adding a document. -->                                                                                                                          id  text     

我遇到了类似的问题,解决方案是使用bundle exec rake运行reindex而不仅仅是rake

 $ bundle exec rake sunspot:solr:stop $ bundle exec rake sunspot:solr:start $ bundle exec rake sunspot:reindex