严重:在“/home/XXXX/searchengine/config/development.sphinx.conf”中找不到索引
FATAL: no indexes found in '/home/XXXX/searchengine/config/development.sphinx.conf'
sphinx 在我想要的时候告诉我这个错误 (rake ts:start)
我正在使用 rails 5.1.4 和 ruby 2.4.1
Sphinx 2.2.9-id64-release (rel22-r5006)
Copyright (c) 2001-2015, Andrew Aksyonoff
Copyright (c) 2008-2015, Sphinx Technologies Inc (http://sphinxsearch.com)
using config file '/home/snoura/searchengine/config/development.sphinx.conf'...
FATAL: no indexes found in '/home/snoura/searchengine/config/development.sphinx.conf'
The Sphinx start command failed:
Command: searchd --pidfile --config "/home/snoura/searchengine/config/development.sphinx.conf"
Status: 1
Output: See above
There may be more information about the failure in /home/snoura/searchengine/log/development.searchd.log.
这就是我的模型 Post.rb
define_index do
indexes content
indexes :name, sortable: true
end
这里有两点要注意。
首先:您使用的是 非常 的旧语法来定义索引(Taryn 对您的问题的评论是正确的)。 define_index
模型中是 Thinking Sphinx v1/v2 的方法。 Thinking Sphinx v3(支持 Rails 3.2 到 5.x 的版本)期望索引定义位于 app/indices
目录中。因此,您需要在其中添加一个文件(可能 post_index.rb
),其中包含以下内容:
ThinkingSphinx::Index.define :post, :with => :active_record do
indexes content
indexes name, sortable: true
end
文档中提供了完整的索引定义语法:
https://freelancing-gods.com/thinking-sphinx/indexing.html
第二点要注意的是,您需要在启动守护程序之前处理您的索引。这意味着 运行 rake ts:index
.
sphinx 在我想要的时候告诉我这个错误 (rake ts:start) 我正在使用 rails 5.1.4 和 ruby 2.4.1
Sphinx 2.2.9-id64-release (rel22-r5006)
Copyright (c) 2001-2015, Andrew Aksyonoff
Copyright (c) 2008-2015, Sphinx Technologies Inc (http://sphinxsearch.com)
using config file '/home/snoura/searchengine/config/development.sphinx.conf'...
FATAL: no indexes found in '/home/snoura/searchengine/config/development.sphinx.conf'
The Sphinx start command failed:
Command: searchd --pidfile --config "/home/snoura/searchengine/config/development.sphinx.conf"
Status: 1
Output: See above
There may be more information about the failure in /home/snoura/searchengine/log/development.searchd.log.
这就是我的模型 Post.rb
define_index do
indexes content
indexes :name, sortable: true
end
这里有两点要注意。
首先:您使用的是 非常 的旧语法来定义索引(Taryn 对您的问题的评论是正确的)。 define_index
模型中是 Thinking Sphinx v1/v2 的方法。 Thinking Sphinx v3(支持 Rails 3.2 到 5.x 的版本)期望索引定义位于 app/indices
目录中。因此,您需要在其中添加一个文件(可能 post_index.rb
),其中包含以下内容:
ThinkingSphinx::Index.define :post, :with => :active_record do
indexes content
indexes name, sortable: true
end
文档中提供了完整的索引定义语法: https://freelancing-gods.com/thinking-sphinx/indexing.html
第二点要注意的是,您需要在启动守护程序之前处理您的索引。这意味着 运行 rake ts:index
.