【问题标题】:Thinking Sphinx search returns (Object doesn't support #inspect)Thinking Sphinx 搜索返回(对象不支持#inspect)
【发布时间】: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>

标签: ruby-on-rails-3 indexing full-text-search sphinx thinking-sphinx


【解决方案1】:

正如 cmets 中所讨论的,问题在于使用旧版本的 mysql2 gem(Thinking Sphinx v3 用于连接到 Sphinx)。最低要求是 0.3.12b4。

(对于那些对为什么它没有被列为 TS gem 的依赖项感兴趣的人,这是因为 mysql2 不能与 JRuby 一起使用)。

【讨论】:

    【解决方案2】:

    thinking-sphinx github 页面上,它声明使用brew install sphinx --mysql 安装sphinx。这解决了我的问题,但在我使用 postgres 时破坏了我的索引。我的解决方案是brew install sphinx --mysql --pgsql 这让我可以索引和搜索。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-12-03
      • 1970-01-01
      • 2015-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-03
      相关资源
      最近更新 更多