我在山狮上为我的 rails 3 应用程序安装了 sphinx 和thinking sphinx (3.0.2),在安装过程中一切似乎都运行良好。我的最终计划是使用 sphinx 的 geodist 功能,但目前我只想确保一切正常。
在我的模型 -story.rb 中,我有一个名为 title 的列,它是字符串类型的。因此,我在 app/indices 中创建了一个文件 story_index.rb,其中包含:
ThinkingSphinx::Index.define :story, :with => :active_record do
indexes title
end
我rake ts:rebuild
生成以下内容:
Stopped searchd daemon (pid: 3185).
Generating configuration to /Users/kevin/Desktop/Development/grumpy/config/development.sphinx.conf
Sphinx 2.0.9-release (r3832)
Copyright (c) 2001-2013, Andrew Aksyonoff
Copyright (c) 2008-2013, Sphinx Technologies Inc (http://sphinxsearch.com)
using config file '/Users/kevin/Desktop/Development/grumpy/config/development.sphinx.conf'...
indexing index 'story_core'...
collected 2 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 2 docs, 36 bytes
total 0.016 sec, 2189 bytes/sec, 121.63 docs/sec
total 3 reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
total 9 writes, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
Started searchd successfully (pid: 3222).
这似乎很好。但是,当我启动 rails 控制台并尝试:
1.9.3-p327 :001 > Story.search "dinosaur"
(Object doesn't support #inspect)
=>
与数据库的连接很好,并且有一些记录应该符合搜索条件。任何想法或解决方案将不胜感激。:)
** 使用 GemFile 更新 **
gem 'jquery-rails', '2.0.2'
gem 'bootstrap-sass', '2.0.0'
gem 'devise', '2.1.2'
gem 'gon', '3.0.5'
gem 'resque', :require => 'resque/server'
gem 'resque-scheduler', :require => 'resque_scheduler'
gem 'thinking-sphinx', '3.0.2'
gem 'kaminari', '0.14.1'