思考Sphinx - 搜索过滤器无效

时间:2010-01-17 23:14:10

标签: ruby-on-rails ruby sphinx thinking-sphinx

我在ruby-on-rails 2.3.2和Windows 7 pc上安装了Sphinx和Thinking Sphinx。

首先,如果我运行rake ts:start,它根本不会启动。它一直说“开始...”,它永远不会开始。即使这样,简单的搜索(没有过滤也没有条件)工作正常。当我尝试添加过滤器时,它不会返回任何记录。

我的模型看起来像这样:

class Announcement < ActiveRecord::Base

  belongs_to :announcement_type
  belongs_to :user
  belongs_to :province
  has_many :announcement_favorites
  has_many :announcement_comments
  has_many :announcement_subscriptions
  has_many :announcement_views
  acts_as_taggable_on :tags #,:category

  validates_presence_of :title, :description, :expirationDate

  define_index do
    indexes title, :as => :title, :sortable => true
    indexes description, :as => :description, :sortable => true

    has province_id, :as => :province_id
  end

我正在这样搜索:

Announcement.search params[:announcement][:search].to_s, :with => {:province_id => 1} ,:page => params[:page], :per_page => 10

基于Think Sphinx思考的所有优秀文档以及我读过的所有帖子,我无法理解我做错了什么。

我只想澄清一下,在我修改索引之后,运行rake ts:index,ts:config命令,然后我重新启动searchd windows服务以防万一,所以应用程序,只是为了确保一切都是刷新。

提前致谢,

布赖恩

1 个答案:

答案 0 :(得分:1)

我认为是:conditions =&gt; {:province_id =&gt; 1}而不是