【发布时间】:2013-05-01 15:31:01
【问题描述】:
我在山狮上为我的 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'
【问题讨论】:
-
您的 Gemfile 中还有什么?如果你运行
Story.seach("dinosaur").first,会发生什么? -
@pat 我已经用我正在使用的其他一些宝石更新了我的问题。当我使用 .first 运行时,我得到 - #<0x6ef58d8><:client:0x6ef58d8>0x6ef58d8>
标签: ruby-on-rails-3 indexing full-text-search sphinx thinking-sphinx