2013-03-06 11 views
5

Thinking Sphinx for searchを試してみてください。私gemfileにこれらの行を追加し、(私は私のアプリでPGを使用していても、それは明らかに必須です)TSとMySQLをインストール自作でthis Railscastを追っ:Thinking Sphinx - 設定ファイルにインデックスがありません

gem 'mysql2' 
gem 'thinking-sphinx' 

と私のモデルで次のように入れて、他のすべて

下回ります

post.rb

class Post < ActiveRecord::Base 
    #... 

    define_index do 
     indexes content 
     indexes :name 
    end 
end 

それから私はターミナルに入るとすくいTS試してください:インデックスを、私はこのエラーを取得:

using config file '/Users/<personal>/rails_projects/<personal>/config/development.sphinx.conf'... 
    FATAL: no indexes found in config file '/Users/<personal>/rails_projects/<personal>/config/development.sphinx.conf' 

Fishedaroundon the internetこれはかなり答えが見つかりませんでした。私はrake tsを実行しようとしました:configure(それは文句なしです)とrake ts:indexを実行しましたが、うまくいきません。

背景:私はちょうど私の端末シェルを(zshを使うために)変更しました。これは、あらゆる種類の不思議な予期しない変更を加えました。私はbundlerを再インストールしてから、すべての宝石を再バンドルしてから、独立してgem install rakeをインストールする必要がありました。それから、私は良い尺度のために更新したバンドルです今すぐレーキは動作するようですが、私はまだエラーが発生します。

indexer 
{ 
} 

searchd 
{ 
    listen = 127.0.0.1:9306:mysql41 
    log = /Users/<personal>/rails_projects/<personal>/log/development.searchd.log 
    query_log = /Users/<personal>/rails_projects/<personal>/log/development.searchd.query.log 
    pid_file = /Users/<personal>/rails_projects/<personal>/log/development.sphinx.pid 
    workers = threads 
    binlog_path = /Users/<personal>/rails_projects/<personal>/tmp/binlog/development 
} 

で何が起こっているか任意のアイデアを/どのようなコードの答えはであるかもしれない:エラーファイル

configが約不平か?

INTERESTING UPDATE - 私は「Post.sphinx_indexes.length」私のレールコンソールとタイプを入力するthis Google GroupにQ & Aに従ったが、私はお返しに、この非常に異なるエラーを得ました。私のモデルがどうにかして宝石にアクセスできないように見えますか?

NoMethodError: undefined method `define_index' for #<Class:0x007f9c06c611b0> 
     from /Users/<personal>/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/dynamic_matchers.rb:55:in `method_missing' 
     from /Users/<personal>/rails_projects/<personal>/app/models/post.rb:55:in `<class:Post>' 
     from /Users/<personal>/rails_projects/<personal>/app/models/post.rb:13:in `<top (required)>' 
     from /Users/<personal>/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:469:in `load' 
     from /Users/<personal>/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:469:in `block in load_file' 
     from /Users/<personal>/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:639:in `new_constants_in' 
     from /Users/<personal>/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:468:in `load_file' 
     from /Users/<personal>/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:353:in `require_or_load' 
     from /Users/<personal>/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:502:in `load_missing_constant' 
     from /Users/<personal>/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:192:in `block in const_missing' 
     from /Users/<personal>/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:190:in `each' 
     from /Users/<personal>/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:190:in `const_missing' 
     from (irb):1 
     from /Users/<personal>/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands/console.rb:47:in `start' 
     from /Users/<personal>/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands/console.rb:8:in `start' 
     from /Users/<personal>/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:41:in `<top (required)>' 
     from script/rails:6:in `require' 
     from script/rails:6:in `<main>'irb(main):002:0> 

答えて

5

また、Thinking Sphinx Google Groupにこの質問を投稿して回答を得たので、下に貼り付けます。上記の質問に答えた後、私は別のエラーに遭遇し、それをフォローアップしたので、誰かがもっと情報を求めているなら、this discussionはうまくいけば助けになるはずです。

そして、私は引用:

Hi Sasha The issue is that Thinking Sphinx's documentation is mostly for v2, but v3 is what you're using (and much better). Index definitions are now located in app/indices - the README is your best source of information (but anything it doesn't cover is probably the same as earlier versions): https://github.com/pat/thinking-sphinx/blob/master/README.textile

Have a read through of that, move your index definition, and you should be good to go. Any further issues, get in touch :)

-- Pat

その問題の後、私はスフィンクスが私のPostgreSQLデータベースへのアクセス権を持っていなかったので、明らかにしたこの1、に走りました。

indexing index 'post_core'... 
ERROR: source 'post_core_0': unknown type 'pgsql'; skipping. 
ERROR: index 'post_core': failed to configure some of the sources, will not index. 
total 0 reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg 
total 0 writes, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg 

私はスフィンクスとの両方宝石(thinking_sphinxとmysql2)をアンインストールすることによって、これを固定し、次いで宝石を再インストールし、MySQLおよびpgsqlの両方のフラグとスフィンクスをインストール醸造。

その後、rake ts:indexは魅力的に機能しました。

2

エラーの原因として、フォルダとファイルの名前が考えられます。余分なスペース、または 'i'で綴られた添え字はファイルを認識せず、インデックスを生成しません。

見ることができるもの...

+0

ありがとう、ジェローム...正確に私がした - スペルミスの指標。 – backwardm

+0

複数形が1つの場合、私は誤って定義されていると信じています。インデックスはエラーを少なくし、レールになるでしょう。 – Jerome

+0

「索引」は索引付け(索引の処理)のアクションでもあり、混乱を避けたいので、「索引」と一緒に行きました。したがって、可能な限りインデックスの複数形としてインデックスを使用しようとしています。 – pat

関連する問題