【问题标题】:Using solr and sunspot in development Rails在开发 Rails 中使用 solr 和 sunspot
【发布时间】:2014-12-19 10:16:44
【问题描述】:

我正在尝试在我的 rails 应用程序中配置 sunspot,但我希望它可以与安装的 solr-tomcat 一起使用,因为我正在使用 vagrant 来管理开发机器。

我已经使用 apt-get 安装了 solr-tomcat,根据本教程的前两个步骤:https://www.digitalocean.com/community/tutorials/how-to-install-solr-on-ubuntu-14-04

我已将gem sunspot_rails 添加到gemfile,也成功运行rails generate sunspot_rails:install 并相应地配置了我的config/sunspot.xml

production:
  solr:
    hostname: localhost
    port: 8080
    log_level: WARNING
    path: /solr/production

development:
  solr:
    hostname: localhost
    port: 8080
    log_level: INFO
    pid_dir: '/var/run'
  disabled: false

test:
  solr:
    hostname: localhost
    port: 8081
    log_level: WARNING
    path: /solr/test

由于我使用的是 vagrant,我希望它能够开箱即用,适用于可能加入该项目的任何其他开发人员,这就是我不安装 gem sunspot_solr 的主要原因

我感觉我错过了什么,但我不知道为什么。

当我尝试 rake sunspot:solr:reindex 时,它会抛出 HTTP Status 404 - /usr/share/solr/development/update - The requested resource is not available.

** 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: RSolr::Error::Http - 404 Not Found
Error: <html><head><title>Apache Tomcat/6.0.39 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 404 - /solr/default/update</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>/solr/default/update</u></p><p><b>description</b> <u>The requested resource is not available.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/6.0.39</h3></body></html>

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

注意:用户是我的应用程序中的模型

Solr 正在工作,因为我可以毫无问题地访问 localhost:8080/solr/admin

【问题讨论】:

  • 在你的错误信息中你有这个:将 gem 'progress_bar' 添加到你的 Gemfile。照它说的做。
  • 它什么也不做,只是添加进度条来可视化进度;)
  • config/sunspot.xml;错字?它是 config/sunspot.yml
  • 你能澄清为什么'gem sunspot_solr'不能开箱即用。它只是安装了一个 solr 发行版。如果你在虚拟机中做,然后打包 vagrant 文件,你可以共享 vagrant 文件,一切都应该正常工作
  • 你的收藏名称是什么?

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


【解决方案1】:

我已经手动安装了 solr,因为无论如何在 repo 中都是过时的版本,请使用本教程 https://www.digitalocean.com/community/tutorials/how-to-install-solr-on-ubuntu-14-04

然后添加到 gemfile gem sunspot_solr,捆绑并执行 rake sunspot:solr:start 以生成 solr/conf/schema.xml,然后我将其复制到 opt/solr/solr/{APP_NAME}

并像这样配置我的config/sunspot.yml

development:
  solr:
    hostname: localhost
    port: 8983
    log_level: INFO
    path: /solr/{APP_NAME}
    solr_home: solr
  disabled: false

而且它工作正常!

Full notes about the process I've saved as a gist, feel free to use it ;)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多