Ruby on Rails - Solr/Sunspot: 连接被拒绝 - connect(2)

3

这个错误是因为Sunspot无法连接到它配置使用的服务器。你能分享一下你的 sunspot.yml 文件吗? - Nick Zadrozny
您可能也对托管全文搜索解决方案感兴趣,其中提到了我的服务Websolr - Nick Zadrozny
生产环境下sunspot.yml配置的端口是多少? - leenasn
4个回答

5

您可以尝试重新索引

$rake sunspot:solr:reindex RAILS_ENV=production

如果那样做不起作用,您可以...
$rm solr/pids/production/sunspot-solr-production.pid

...启动Solr

$rake sunspot:solr:start RAILS_ENV=production

...然后再次重新索引

$rake sunspot:solr:reindex RAILS_ENV=production

3

事实证明,在所有的故障排除之后,问题其实就是配置文件中端口号的问题(以某种拖沓的方式)-- 即Sunspot.config.solr.url


1
Sunspot.config.solr.url = 'http://localhost:8983/solr' 添加到 config/production.rb 中同样有效。 - foz

2

有人能帮我让这个工作起来吗?

$rake sunspot:solr:start RAILS_ENV=production$

在生产环境中使用Rails设置sunspot solr表明它确实就像这样简单。

你能具体说明一下你尝试这个方法时遇到的问题吗?或者是什么原因导致你没有尝试?因为安装solr/tomcat等比输入那一行代码要复杂得多。

如果你决定进行完整的tomcat/solr安装,也可以尝试http://internetmodulation.com/2011/01/10/sunspot-solr-tomcat-ubunut.html.html


0

这篇博客可能会解决你的问题:

在 CentOS 上安装 Solr 4.4 并使用 Jetty,以及设置 Solr 服务器与 Sunspot Gem 合作。( http://blogs.pigrider.com/blogs/26

以下是该博客中的一些部分: ......

8)将 Rails 应用程序中的配置文件 schema.yml 复制到正在运行的 Solr 4.4 实例的主目录中。它将覆盖 Solr 示例配置文件,并设置 Solr 4.4 服务器与 Sunspot Gem 合作。 cp /RailsApplicationPath/Solr/conf/schema.yml /opt/solr/solr/collection1/conf/。

正在运行的 Solr 4.4 实例的主目录为 /opt/solr/solr/collection1/。您可以从 Solr 管理页面(http:// l o c a l h o s t :8983/solr/admin)找到此信息。

9)将 version 字段添加到配置文件 schema.yml 中,以满足 Solr 4.4 的初始化要求。实际上需要将两行代码添加到文件中。它们是:

<field name="_version_" type="long" indexed="true" stored="true" multiValued="false"/>

<fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>

配置文件 schema.yml 最终将会如下所示:

<schema name="sunspot" version="1.0">
  <types>
    <fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>
    <!-- *** Other Sunspot fieldType Definitions *** -->
  </types>

  <fields>
    <field name="_version_" type="long" indexed="true" stored="true" multiValued="false"/>
    <!-- *** Other Sunspot field Definitions *** -->
  </fields>

  <!-- *** Other Sunspot Configurations *** -->
</schema>

......


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接