无法搜索特定索引

时间:2011-02-15 12:04:36

标签: thinking-sphinx

型号:

class TechRequest < ActiveRecord::Base
...
  define_index do
  ...
    indexes  :hot_request
    indexes :status_id, :as => :current_status_id
  ...
    has :hot_request , :as => :hot_request
    set_property :delta => true
  end

DB:

hot_request - tinyint(1)

当我执行控制器代码时 -

@query_string = '(@hot_request 1)(@current_status_id 1 | 2 | 3)'
@tech_requests = TechRequest.search @query_string, :match_mode => :extended

抛出以下错误:

ThinkingSphinx::SphinxError: index tech_request_core,tech_request_delta: query error: no field 'tech_hot_request' found in schema
        from D:/Current/TechAssistTest/vendor/plugins/thinking-sphinx/lib/thinking_sphinx/search.rb:392:in 'populate'
        from D:/Current/TechAssistTest/vendor/plugins/thinking-sphinx/lib/thinking_sphinx/search.rb:508:in 'call'
        from D:/Current/TechAssistTest/vendor/plugins/thinking-sphinx/lib/thinking_sphinx/search.rb:508:in 'retry_on_stale_index'
        from D:/Current/TechAssistTest/vendor/plugins/thinking-sphinx/lib/thinking_sphinx/search.rb:379:in 'populate'
        from D:/Current/TechAssistTest/vendor/plugins/thinking-sphinx/lib/thinking_sphinx/search.rb:167:in 'method_missing'
        from D:/ruby/lib/ruby/1.8/irb.rb:302:in 'output_value'
        from D:/ruby/lib/ruby/1.8/irb.rb:151:in 'eval_input'
        from D:/ruby/lib/ruby/1.8/irb.rb:263:in 'signal_status'
        from D:/ruby/lib/ruby/1.8/irb.rb:147:in 'eval_input'
        from D:/ruby/lib/ruby/1.8/irb.rb:146:in 'eval_input'
        from D:/ruby/lib/ruby/1.8/irb.rb:70:in 'start'
        from D:/ruby/lib/ruby/1.8/irb.rb:69:in 'catch'
        from D:/ruby/lib/ruby/1.8/irb.rb:69:in 'start'
        from D:/ruby/bin/irb:13

当我使用hot_request作为属性时,搜索工作正常。该 当我使用@query_string = '(@current_status_id 1 | 2 | 3)'时,搜索也可以正常工作。

1 个答案:

答案 0 :(得分:0)

我遇到了类似的问题 - 我可以看到这两个错误的原因有两个。首先,根据http://sphinxsearch.com/forum/view.html?id=2103,您可以使用sql列作为字段或属性,但不能同时使用(不克隆它)。另一个让我感到困惑的是,你可能需要指定类型 - 所以如果hot_request实际上是一个整数,你可能需要像

这样的东西

索引hot_request:as =&gt; hr,:type =&gt; :整数

或者你得到了那个神秘的错误信息

希望这有助于某人...