ThinkingSphinx错误:此类过滤器属性

Swa*_*wal 2 search thinking-sphinx ruby-on-rails-3

我正在尝试使用docThinkingSphinx集成到我的项目中.对于一个模型属性和我创建了索引为:User first_namelast_name

User.rb

define_index do
  indexes :first_name
  indexes :last_name
end
Run Code Online (Sandbox Code Playgroud)

然后我运行命令:

rake ts:index
rake ts:start
Run Code Online (Sandbox Code Playgroud)

这开始我的搜索.当我使用以下命令搜索时,我得到结果:

User.search('swati')
Run Code Online (Sandbox Code Playgroud)

但是当我跑的时候

User.search :with => {:first_name => "swati"}
Run Code Online (Sandbox Code Playgroud)

它给了我错误:

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>'
Run Code Online (Sandbox Code Playgroud)

我在stackoverflow上搜索了一个可能的解决方案,并且已经要求它运行命令rake ts:indexrake ts:rebuild.我已经运行了这个命令,但它没有帮助我.

请帮我找出解决方案.

非常感谢.

pab*_*rti 6

您应该创建一个属性与具有索引,重建,然后用

has :first_name
Run Code Online (Sandbox Code Playgroud)

具有创建一个属性,并且被用作过滤器(用于属性)http://pat.github.com/ts/en/searching.html#filters

另请查看http://pat.github.com/ts/en/indexing.html#attributes以获取过滤器.