試圖使用Thinking Sphinx進行搜索。其次是自制軟件安裝TS和MySQL(雖然我在我的應用程序所使用的PG,它顯然是必需的)this Railscast,這些行添加到我的Gemfile:思維獅身人面像 - 在配置文件中找不到索引
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(它不會抱怨),然後耙ts:index,但它不起作用。
一些背景:我只是改變了我的終端shell(使用zsh),這使得各種奇怪的意想不到的變化。我不得不重新安裝捆綁軟件,然後重新安裝我所有的寶石,然後獨立安裝耙寶石。然後我捆綁更新爲好措施。現在耙似乎工作,但我仍然得到錯誤。
配置文件中的錯誤是抱怨:
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
}
任何想法是怎麼回事/什麼代碼,答案可能是嗎?
有趣UPDATE - 我跟着第q & A於this Google Group進入我的rails控制檯,輸入「Post.sphinx_indexes.length」,但我得到的回報這個非常不同的錯誤。看起來我的模型不知何故無法獲得寶石?
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>
謝謝傑羅姆......正是我所做的 - 拼寫錯誤的指數。 – backwardm 2014-06-25 18:48:19
一種情況下多的是,我相信,misdefined。索引會導致更少的錯誤,併成爲鐵路專家。 – Jerome 2014-06-26 09:05:32
我去「指數」,因爲「指標」也是分度的動作(處理索引),我想,以避免混淆。因此,我儘量使用索引作爲索引的複數。 – pat 2014-08-13 15:00:27