在生产环境中使用 Rails 设置 sunspot solr

发布于 2024-10-16 05:28:46 字数 167 浏览 2 评论 0原文

我尝试了各种链接,但我似乎找不到关于创建与生产中的 Rails 一起运行的 solr 实例的好资源。

我知道您必须为生产设置 solr 服务器。我已经尝试使用 tomcat 设置 solr,但我似乎无法将其链接到 Rails 应用程序。

有什么好的资源可供我使用吗?

谢谢

I have tried various links but I can't seem to find a good resource on creating a running solr instance that works with rails in production.

I understand that you have to setup the solr server for production. I have tried the setup of solr with tomcat but I cant seem to link it to the rails app.

Is there any good resource out there that I could use?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

美人骨 2024-10-23 05:28:46

Sunspot gem 包含 sunspot-solr 二进制文件。最简单的设置就是运行 sunspot-solr start。根据应用程序的部署方式,您还可以在 Capistrano 部署中包含一个任务,该任务使用 Sunspot 提供的 rake 任务来启动 Solr 服务器。即,rake sunspot:solr:start RAILS_ENV=product

更深入地了解可能涉及:将 Tomcat 安装为独立服务,使用其自己的 init 脚本启动和停止(或 Upstart config),最好由 monit 或 god 监控;在 Tomcat 中下载并部署 solr.war,并配置 solr.xml 以引用磁盘上索引数据的方便位置,solrconfig.xmlschema.xml被存储。

Solr wiki 还包含一个关于使用 Tomcat 安装 Solr其他 servlet 容器

在上述任一自托管选项中,对于 Sunspot 有一点需要牢记:禁用其自动提交,并依赖 solrconfig.xmlautoCommit 设置>。您可以通过在 config/sunspot.yml 中设置 auto_commit_after_request: false 来禁用这些提交。

最后,如果您对外包所有这些更感兴趣,还有我自己的托管 Solr 服务 http://websolr .com/ — 只需点击几下,我们就可以让您启动并运行。

The Sunspot gem includes the sunspot-solr binary. The simplest setup would be just to run sunspot-solr start. Depending on how your application is deployed, you might also include a task in your Capistrano deploy that uses Sunspot's provided rake task to start a Solr server. Namely, rake sunspot:solr:start RAILS_ENV=production.

Getting more in-depth from that could involve: installing Tomcat as a standalone service, started and stopped with its own init script (or Upstart config), ideally monitored by monit or god; downloading and deploying solr.war within Tomcat, and configuring the solr.xml to refer to a convenient location on disk for your index data, solrconfig.xml and schema.xml to be stored.

The Solr wiki also includes a page on installing Solr with Tomcat and other servlet containers.

In either of the above self-hosted options, there's an important point to keep in mind with Sunspot: disable its automatic commits, and rely on Solr's own autoCommit settings in solrconfig.xml. You can disable those commits by setting auto_commit_after_request: false in your config/sunspot.yml.

Finally, if you're more interested in just outsourcing all of this, there's also my own humble hosted Solr service over at http://websolr.com/ — we can have you up and running in just a few clicks.

羁拥 2024-10-23 05:28:46

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

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

以下是来自博客:
......

8) 将此配置文件 schema.yml 从 Rails 应用程序复制到正在运行的 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:// localhost :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>

......

This blog may solve your question:

Install Solr 4.4 with Jetty in CentOS, and set up Solr server to work with Sunspot Gem. ( http://blogs.pigrider.com/blogs/26 )

Below are some parts from the blog:
......

8) Copy this configuration file schema.yml from your Rails application to the home directory of the running Solr 4.4 instance. It will overrider the Solr example configuration file there, and it will set up Solr 4.4 server to work with Sunspot Gem.
cp /RailsApplicationPath/Solr/conf/schema.yml /opt/solr/solr/collection1/conf/.

The home directory of the running Solr 4.4 instance is /opt/solr/solr/collection1/. You can find this information from Solr admin page http:// l o c a l h o s t :8983/solr/admin

9) Add version field into the configuration file schema.yml to satisfy Solr 4.4 initialization requirement. Actually, two lines of code need to be added into the file. They are:

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

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

The configuration file schema.yml eventually will look like:

<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>

......

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文