3

Rails 3アプリ用にマウンテンライオンにスフィンクスと思考スフィンクス(3.0.2)をインストールしましたが、インストール中にすべてが正常に動作しているようです。私の最終的な計画は、スフィンクスのジオディスト機能を使用することですが、現時点では、すべてがうまく機能していることを確認したいだけです.

私のモデル - story.rb には、文字列型の title という列があります。したがって、app/indices に、以下を含むファイル story_index.rb を作成しました。

ThinkingSphinx::Index.define :story, :with => :active_record do
  indexes title
end

Myrake 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)
 =>  

DB への接続は良好で、検索基準に適合するレコードがいくつかあります。どんなアイデアや解決策も大歓迎です。:)

** 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'
4

2 に答える 2

4

コメントで説明されているように、問題は mysql2 gem (Thinking Sphinx v3 が Sphinx への接続に使用する) の古いバージョンを使用していることです。最小要件は 0.3.12b4 です。

(TS gem の依存関係として記載されていない理由に興味がある方は、mysql2 が JRuby で動作しないためです)。

于 2013-05-02T15:55:00.957 に答える
2

thinking-sphinx githubページには、sphinxをインストールするように記載されていますbrew install sphinx --mysql. これで問題は解決しましたが、postgres を使用していたため、インデックス作成が壊れました。私の解決策はbrew install sphinx --mysql --pgsql、これによりインデックスと検索が可能になることでした。

于 2013-06-17T02:50:50.980 に答える