我在我的Rails3应用程序上安装了sphinx和thinking (3.0.2),在安装过程中一切似乎都运行得很好。我的最终计划是使用sphinx的geodist特性,但目前我只希望确保一切工作正常。
在我的模型- story.rb中,我有一个名为title的列,它是string类型的。因此,我在app/ in中创建了一个文件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'发布于 2013-05-02 23:55:01
正如评论中所讨论的,问题是使用旧版本的Sphinx (Sphinx v3使用它连接到Sphinx)。最低要求是0.3.12b4。
(对于那些感兴趣的人来说,为什么它没有被列为TS gem的依赖项,这是因为mysql2不能与JRuby一起工作)。
发布于 2013-06-17 10:50:51
在thinking-sphinx github页面上,它指出要在brew install sphinx --mysql中安装sphinx。这解决了我的问题,但在我使用postgres时破坏了我的索引。我的解决方案是brew install sphinx --mysql --pgsql,这允许我索引和搜索。
https://stackoverflow.com/questions/16321211
复制相似问题