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
答案 0 :(得分:0)
这里有两点需要注意。
首先:您使用非常旧语法来定义索引(Taryn对您的问题的评论是正确的)。模型中的define_index
是Thinking Sphinx v1 / v2的方法。思考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
。