思考Sphinx过滤has_one关联中的字符串字段

时间:2012-09-14 04:45:44

标签: ruby-on-rails-3 postgresql filtering thinking-sphinx

不知道这里有什么问题。我正在尝试过滤state关联的address属性。

class Organization < ActiveRecord::Base
  has_one :address, :as => :addressable, :dependent => :destroy

  define_index do
    indexes :name, :sortable => true

    has mec_revenue
    has 'CRC32(status)', :as => :status, :type => :integer
    has 'CRC32(address.state)', :as => :state, :type => :integer
    set_property :delta => true
  end

end

但是当我运行rake ts:index时,我收到以下错误。

indexing index 'organization_delta'...
ERROR: index 'organization_delta': sql_range_query: ERROR:  missing FROM-clause entry for table "address"
LINE 1: ...S "mec_revenue", CRC32(status) AS "status", CRC32(address.st...

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

我不确定如何修复FROM子句问题,但如果我使用表名而不是属性名,我可以使用group_by子句来修复它。

has 'CRC32(addresses.state)', :as => :state, :type => :integer
group_by "addresses.state"