【问题标题】:Sunspot-Rails fails to reindex in productionSunspot-Rails 未能在生产中重新索引
【发布时间】:2015-12-09 18:39:20
【问题描述】:

我有以下环境:

Solr 5.3.1 Ubuntu 15.04 导轨 4.4.2 太阳黑子轨道

我的 solr 实例已启动并正在运行,我的生产集合是通过运行创建的

/opt/solr/bin/solr create -c production

从我的生产环境中,我进入 rake 以重新索引并运行如下:rake sunspot:solr:reindex。其结果是以下 http 400 错误:

deploy@vps194508:/opt/www/app1/current/bin$ bundle exec rake sunspot:solr:reindex
(in /opt/www/app1/releases/20151209181633)
Skipping progress bar: for progress reporting, add gem 'progress_bar' to your Gemfile
rake aborted!
RSolr::Error::Http: RSolr::Error::Http - 400 Bad Request
Error: {'responseHeader'=>{'status'=>400,'QTime'=>4},'error'=>{'msg'=>'undefined field type','code'=>400}}

URI: http://app1.com:8983/solr/production/update?wt=ruby
Request Headers: {"Content-Type"=>"text/xml"}
Request Data: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><delete><query>type:Event</query></delete>"

Backtrace: /opt/www/app1/shared/bundle/ruby/2.2.0/gems/rsolr-1.0.13/lib/rsolr/client.rb:284:in `adapt_response'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/rsolr-1.0.13/lib/rsolr/client.rb:190:in `execute'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/rsolr-1.0.13/lib/rsolr/client.rb:176:in `send_and_receive'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/sunspot_rails-2.2.2/lib/sunspot/rails/solr_instrumentation.rb:16:in `block in send_and_receive_with_as_instrumentation'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.2/lib/active_support/notifications.rb:164:in `block in instrument'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.2/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.2/lib/active_support/notifications.rb:164:in `instrument'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/sunspot_rails-2.2.2/lib/sunspot/rails/solr_instrumentation.rb:15:in `send_and_receive_with_as_instrumentation'
(eval):2:in `post'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/rsolr-1.0.13/lib/rsolr/client.rb:82:in `update'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/rsolr-1.0.13/lib/rsolr/client.rb:146:in `delete_by_query'/opt/www/app1/shared/bundle/ruby/2.2.0/gems/rsolr-1.0.13/lib/rsolr/client.rb:284:in `adapt_response'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/rsolr-1.0.13/lib/rsolr/client.rb:190:in `execute'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/rsolr-1.0.13/lib/rsolr/client.rb:176:in `send_and_receive'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/sunspot_rails-2.2.2/lib/sunspot/rails/solr_instrumentation.rb:16:in `block in send_and_receive_with_as_instrumentation'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.2/lib/active_support/notifications.rb:164:in `block in instrument'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.2/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.2/lib/active_support/notifications.rb:164:in `instrument'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/sunspot_rails-2.2.2/lib/sunspot/rails/solr_instrumentation.rb:15:in `send_and_receive_with_as_instrumentation'
(eval):2:in `post'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/rsolr-1.0.13/lib/rsolr/client.rb:82:in `update'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/rsolr-1.0.13/lib/rsolr/client.rb:146:in `delete_by_query'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/sunspot-2.2.2/lib/sunspot/indexer.rb:68:in `remove_all'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/sunspot-2.2.2/lib/sunspot/session.rb:197:in `block in remove_all'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/sunspot-2.2.2/lib/sunspot/session.rb:197:in `each'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/sunspot-2.2.2/lib/sunspot/session.rb:197:in `remove_all'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/sunspot-2.2.2/lib/sunspot/session_proxy/abstract_session_proxy.rb:11:in `remove_all'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/sunspot-2.2.2/lib/sunspot/session_proxy/retry_5xx_session_proxy.rb:17:in `method_missing'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/sunspot-2.2.2/lib/sunspot/session_proxy/abstract_session_proxy.rb:11:in `remove_all'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/sunspot-2.2.2/lib/sunspot.rb:502:in `remove_all'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/sunspot_rails-2.2.2/lib/sunspot/rails/searchable.rb:190:in `solr_remove_all_from_index'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/sunspot_rails-2.2.2/lib/sunspot/rails/searchable.rb:209:in `solr_reindex'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/sunspot_rails-2.2.2/lib/sunspot/rails/tasks.rb:60:in `block (4 levels) in <top (required)>'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/sunspot-2.2.2/lib/sunspot/class_set.rb:16:in `each'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/sunspot-2.2.2/lib/sunspot/class_set.rb:16:in `each'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/sunspot_rails-2.2.2/lib/sunspot/rails/tasks.rb:59:in `block (3 levels) in <top (required)>'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/sunspot_rails-2.2.2/lib/sunspot/rails/tasks.rb:71:in `with_session'
/opt/www/app1/shared/bundle/ruby/2.2.0/gems/sunspot_rails-2.2.2/lib/sunspot/rails/tasks.rb:19:in `block (2 levels) in <top (required)>'
Tasks: TOP => sunspot:solr:reindex => sunspot:reindex
(See full trace by running task with --trace)

有人可以解释为什么会发生这种情况以及我该如何解决它。在开发中一切正常。在生产中,我的生产集合是空的,因此尝试重新索引,但它失败并出现这个错误的请求 400 错误。

【问题讨论】:

    标签: ruby-on-rails solr lucene sunspot-rails sunspot-solr


    【解决方案1】:

    我错过了一个重要的配置点,我在 sunspot-rails 文档中没有看到。

    当您为 sunspot-rails 运行 rake install 命令时,它会在您的 rails 项目的根目录中创建一个 solr 目录。

    其中有两个重要文件:

    solr/configsets/sunspot/conf/schema.xml
    solr/configsets/sunspot/conf/solrconfig.xml
    

    这两个 xml 文件都需要复制到 /var/solr/data/production/conf 目录 - 或者您的集合的任何 conf 目录。当我这样做时,重新启动 solr 并尝试重新索引它的工作原理!瞧。

    【讨论】:

    • 当您使用 core create 命令创建名为“production”的核心时,您没有告诉它使用哪个配置集。这将使用 basic_configs 或 data_driven_schema_configs,但我不确定哪个——它将信息从那里复制到生产目录——而不是 sunspot-rails 包含的配置/模式。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-18
    • 2013-08-06
    相关资源
    最近更新 更多