【问题标题】:Thinking Sphinx filtering on a string field in a has_one association在 has_one 关联中考虑对字符串字段进行 Sphinx 过滤
【发布时间】:2012-09-14 04:45:43
【问题描述】:

无法判断这里出了什么问题。我正在尝试过滤我的address 关联的state 属性。

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...

有什么想法吗?

【问题讨论】:

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


    【解决方案1】:

    我不确定如何解决 FROM 子句问题,但如果我使用表名而不是属性名,我可以使用 group_by 子句来解决这个问题。

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

    【讨论】:

      猜你喜欢
      • 2013-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-19
      • 2012-07-10
      • 1970-01-01
      • 2011-09-17
      • 2022-01-17
      相关资源
      最近更新 更多