简体   繁体   English

无法在Rails应用中使用黑子/ solr重新编制索引-错误:solr配置中存在严重错误

[英]Can't reindex with sunspot / solr in rails app - Error: Severe errors in solr configuration

Ok, so I have a simple rails application and now i'm trying to implement sunspot for search capabilities. 好的,所以我有一个简单的Rails应用程序,现在我正在尝试实现黑子的搜索功能。 However, after I've generated the config file with rails g sunspot_rails:install and after I've started the server and it has made the solr-dir in my rails app-dir and i run bundle exec rake sunspot:solr:reindex I get the following trace: 但是,在用rails g sunspot_rails:install生成配置文件之后,在启动服务器后,它在我的rails app-dir中创建了solr-dir,然后运行bundle exec rake sunspot:solr:reindex我得到以下跟踪:

cakism@saraswati:~/railscode/calendar$ bundle exec rake sunspot:solr:reindex --trace
** Invoke sunspot:solr:reindex (first_time)
** Invoke sunspot:reindex (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute sunspot:reindex
Skipping progress bar: for progress reporting, add gem 'progress_bar' to your Gemfile
rake aborted!
RSolr::Error::Http - 500 Internal Server Error
Error: Severe errors in solr configuration.

Check your log files for more detailed information on what may be wrong.

If you want solr to continue after configuration errors, change:

 <abortOnConfigurationError>false</abortOnConfigurationError>

in null

-------------------------------------------------------------

Request Data: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><delete><query>type:Event</query></delete>"

Backtrace: /var/lib/gems/1.8/gems/rsolr-1.0.7/lib/rsolr/client.rb:230:in `adapt_response'
/var/lib/gems/1.8/gems/rsolr-1.0.7/lib/rsolr/client.rb:167:in `execute'
/var/lib/gems/1.8/gems/rsolr-1.0.7/lib/rsolr/client.rb:161:in `send_and_receive'
(eval):2:in `post'
/var/lib/gems/1.8/gems/rsolr-1.0.7/lib/rsolr/client.rb:67:in `update'
/var/lib/gems/1.8/gems/rsolr-1.0.7/lib/rsolr/client.rb:131:in `delete_by_query'
/var/lib/gems/1.8/gems/sunspot-1.3.0/lib/sunspot/indexer.rb:55:in `remove_all'
/var/lib/gems/1.8/gems/sunspot-1.3.0/lib/sunspot/session.rb:181:in `remove_all'
/var/lib/gems/1.8/gems/sunspot-1.3.0/lib/sunspot/session.rb:181:in `each'
/var/lib/gems/1.8/gems/sunspot-1.3.0/lib/sunspot/session.rb:181:in `remove_all'
/var/lib/gems/1.8/gems/sunspot-1.3.0/lib/sunspot/session_proxy/abstract_session_proxy.rb:11:in `remove_all'
/var/lib/gems/1.8/gems/rsolr-1.0.7/lib/rsolr/client.rb:230:in `adapt_response'
/var/lib/gems/1.8/gems/rsolr-1.0.7/lib/rsolr/client.rb:167:in `execute'
/var/lib/gems/1.8/gems/rsolr-1.0.7/lib/rsolr/client.rb:161:in `send_and_receive'
(eval):2:in `post'
/var/lib/gems/1.8/gems/rsolr-1.0.7/lib/rsolr/client.rb:67:in `update'
/var/lib/gems/1.8/gems/rsolr-1.0.7/lib/rsolr/client.rb:131:in `delete_by_query'
/var/lib/gems/1.8/gems/sunspot-1.3.0/lib/sunspot/indexer.rb:55:in `remove_all'
/var/lib/gems/1.8/gems/sunspot-1.3.0/lib/sunspot/session.rb:181:in `remove_all'
/var/lib/gems/1.8/gems/sunspot-1.3.0/lib/sunspot/session.rb:181:in `each'
/var/lib/gems/1.8/gems/sunspot-1.3.0/lib/sunspot/session.rb:181:in `remove_all'
/var/lib/gems/1.8/gems/sunspot-1.3.0/lib/sunspot/session_proxy/abstract_session_proxy.rb:11:in `remove_all'
/var/lib/gems/1.8/gems/sunspot-1.3.0/lib/sunspot.rb:464:in `remove_all'
/var/lib/gems/1.8/gems/sunspot_rails-1.3.0/lib/sunspot/rails/searchable.rb:178:in `solr_remove_all_from_index'
/var/lib/gems/1.8/gems/sunspot_rails-1.3.0/lib/sunspot/rails/searchable.rb:197:in `solr_reindex'
/var/lib/gems/1.8/gems/sunspot_rails-1.3.0/lib/sunspot/rails/tasks.rb:54
/var/lib/gems/1.8/gems/sunspot-1.3.0/lib/sunspot/class_set.rb:16:in `each'
/var/lib/gems/1.8/gems/sunspot-1.3.0/lib/sunspot/class_set.rb:16:in `each'
/var/lib/gems/1.8/gems/sunspot_rails-1.3.0/lib/sunspot/rails/tasks.rb:53
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `execute'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `invoke_prerequisites'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `each'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `top_level'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `top_level'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `run'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/var/lib/gems/1.8/gems/rake-0.9.2.2/bin/rake:33
/var/lib/gems/1.8/bin/rake:19:in `load'
/var/lib/gems/1.8/bin/rake:19
Tasks: TOP => sunspot:solr:reindex => sunspot:reindex

I am specially curious about this: 我对此特别好奇:

If you want solr to continue after configuration errors, change:

 <abortOnConfigurationError>false</abortOnConfigurationError>

in null

Why would it say in null? 为什么会说空? Other posts with the same problem as I have has specified the solr/conf/solrconfig.xml, and also, when I change it to false, nothing else happens. 与我有相同问题的其他帖子已经指定了solr / conf / solrconfig.xml,并且,当我将其更改为false时,也没有发生任何其他事情。

If I remove the searchable block from my model, I don't get any error (but I suppose that's because it doesn't try to do anything then) 如果我从模型中删除了可搜索的块,那么我不会收到任何错误(但是我想那是因为那时候它不会尝试执行任何操作)

I've run the config file through an XML validator, and it says it's bad start-tag name at 2<-1 5<-2 6<90%. 我已经通过XML验证器运行配置文件,它说它的开始标记名称不好,为2 <-1 5 <-2 6 <90%。 However, even if I remove the lines which then gives a valid XML, restart solr, and try to reindex, I still get the same error. 但是,即使我删除了给出有效XML的行,重新启动solr,并尝试重新索引,我仍然会遇到相同的错误。

I'm starting to get desperate here, so any help is greatly appriciated! 我在这里开始感到绝望,因此对您的帮助非常感激!

I was having a very similar problem and solved it by 我遇到了一个非常相似的问题,并通过

  • stopping all running solr processes 停止所有正在运行的Solr进程
  • removing the solr folder 删除solr文件夹
  • turn off/restart the computer 关闭/重新启动计算机
  • gem uninstall all related gems gem卸载所有相关的gem
  • bundle install 捆绑安装
  • start solr 开始solr
  • reindex solr 重新编制索引

it happened to me occasionally.. in my case it was solr (not sunspot) issue 偶尔发生在我身上..就我而言,这是solr(不是黑子)问题

try to go to 尝试去

http://localhost:8982/solr/admin

or http://localhost:8983/solr/admin

or http://[your.domain]:8983/solr/admin

(depending on what environment you use) (取决于您使用的环境)

to see what error you have under solr web server 看看您在solr Web服务器下有什么错误

i saw the java error message and fixed it with just deleting index directory and restarting solr 我看到了Java错误消息,并通过删除索引目录并重新启动solr进行了修复

and it began to behave as expected 它开始表现出预期

hope it helped 希望能有所帮助

or you can re install the gem. 或者您可以重新安装gem。 This works for me. 这对我有用。

Here is the easy way ( does not require messing with gems or restarting computer ): 这是简单的方法( 不需要弄乱gem或重新启动计算机 ):

rake sunspot:solr:stop

If you have modified the schema, copy the contents of site_root/solr/conf/schema.xml to your clipboard 如果您已修改架构, site_root/solr/conf/schema.xml的内容复制到剪贴板中

Next, delete the entire solr folder at site_root/solr 接下来,删除site_root/solr的整个solr文件夹

Now run: 现在运行:

rake sunspot:solr:start

This command will create and repopulate the deleted solr folder. 此命令将创建并重新填充已删除的solr文件夹。

If you copied schema.xml above, open schema.xml again, select everything, and copy the contents of your clipboard. 如果您在上面复制了schema.xml,请再次打开schema.xml,选择所有内容,然后复制剪贴板的内容。 Save the file. 保存文件。

Now run: 现在运行:

bundle exec rake sunspot:solr:reindex

More specifically, I found out the cause for my problem, hope this helps any souls who was wondering what happened 更具体地说,我找出了问题的原因,希望这对任何想知道发生了什么的人有所帮助

First, I deleted the solr/data folder. 首先,我删除了solr / data文件夹。 Bad idea. 馊主意。 And this caused the errors as described by cakism. 这就导致了错误,如cakism所述。

Restarting, deleting solr folder, etc. won't help. 重新启动,删除solr文件夹等将无济于事。 Simply because there is an instance of Solr server running and it will not be stopped even with sunspot:solr:stop. 仅仅因为有一个正在运行的Solr服务器实例,即使使用sunspot:solr:stop也不会停止它。 You have to kill that instance by: 您必须通过以下方式杀死该实例:

rake sunspot:solr:stop # stop server
ps -A | grep solr      # you'll see the [PID] of the solr server
kill [PID]             # replace with the [PID] from above to completely kill the solr instance

After this, you can then proceed with deleting the solr folder and starting the server again 之后,您可以继续删除solr文件夹并重新启动服务器

I was facing same issue, and finally I got config/database.yml has wrong database name and, than I checked sunspot.yml, this file has also wrong configuration like ip address. 我遇到了同样的问题,最后我得到config / database.yml具有错误的数据库名称,而且比我检查sunspot.yml时,此文件还具有错误的配置,例如ip地址。 I modify both of file than it start to work. 我修改两个文件都比它开始工作。

For me, there was so much dependency with turn off/restart the computer (It was not possible to restart) and does not work any thing from above(I am not trying with restart). 对我来说, turn off/restart the computer有很大的依赖性(无法重新启动),并且从上面无法执行任何操作(我不尝试重新启动)。 So, my working solution was 所以,我的工作解决方案是

  1. Go to app root directory. 进入应用根目录。
  2. using ps aux | grep solr 使用ps aux | grep solr ps aux | grep solr find solr process ID ps aux | grep solr查找solr process ID
  3. stop solr process using kill -9 4313 # for me 4313 was solr process id 使用kill -9 4313停止solr进程kill -9 4313 #对我来说4313是solr进程ID
  4. start solr on staging rake sunspot:solr:start RAILS_ENV=staging 在暂存rake sunspot:solr:start RAILS_ENV=staging上启动solr rake sunspot:solr:start RAILS_ENV=staging

  5. re-index solr using rake sunspot:solr:reindex RAILS_ENV=staging 使用rake sunspot:solr:reindex RAILS_ENV=staging重新索引solr rake sunspot:solr:reindex RAILS_ENV=staging

That's it. 而已。

NB: Replace environment according your need 注意: 根据需要更换环境

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM