2012-11-23 16 views
2

我正在嘗試使用docThinkingSphinx整合到我的項目中。對於User模型屬性first_namelast_name我已經創建的索引爲:ThinkingSphinx錯誤:這樣的篩選器屬性

User.rb

define_index do 
    indexes :first_name 
    indexes :last_name 
end 

然後我運行命令:

rake ts:index 
rake ts:start 

這將啓動我的搜索。我得到的結果時,我用下面的命令來搜索:

User.search('swati') 

但是當我運行

User.search :with => {:first_name => "swati"} 

它給我的錯誤:

Sphinx Sphinx Daemon returned error: index user_core: no such filter attribute 'first_name' 
Sphinx Caught Sphinx exception: index user_core: no such filter attribute 'first_name' (0 tries left) 
ThinkingSphinx::SphinxError: index user_core: no such filter attribute 'first_name' 
from /home/swati/.rvm/gems/ruby-1.9.3-p286/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/search.rb:438:in `block in populate' 
from /home/swati/.rvm/gems/ruby-1.9.3-p286/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/search.rb:606:in `call' 
from /home/swati/.rvm/gems/ruby-1.9.3-p286/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/search.rb:606:in `retry_on_stale_index' 
from /home/swati/.rvm/gems/ruby-1.9.3-p286/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/search.rb:426:in `populate' 
from /home/swati/.rvm/gems/ruby-1.9.3-p286/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/search.rb:187:in `method_missing' 
from /home/swati/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/commands/console.rb:47:in `start' 
from /home/swati/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/commands/console.rb:8:in `start' 
from /home/swati/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/commands.rb:41:in `<top (required)>' 
from script/rails:6:in `require' 
from script/rails:6:in `<main>' 

我搜索了一個可能的解決方案在計算器上,它已被要求運行命令rake ts:indexrake ts:rebuild。我已經運行這個命令,但它並沒有幫助我。

請幫我找出解決方案。

非常感謝。

回答

3

要小心,rake ts:reindexrake ts:rebuild是不同的。

如果添加新索引,則需要重新編譯。

如果你像我一樣偏執,嘗試一切:

rake ts:rebuild 
rake ts:reindex 
rake ts:restart 

如果還是不行,請確保您的索引是defined properly