Thinking sphinx 思考Sphinx-如何在可能为零的关联模型中索引值?
我正在尝试在我的类别模型上定义以下索引:Thinking sphinx 思考Sphinx-如何在可能为零的关联模型中索引值?,thinking-sphinx,Thinking Sphinx,我正在尝试在我的类别模型上定义以下索引: define_index do has document.author.name :as => :author_name, :facet => true end 我的模型定义如下: class Category < ActiveRecord::Base has_many: documents end class Author ActiveRecord::Base has_many :documents end clas
define_index do
has document.author.name :as => :author_name, :facet => true
end
我的模型定义如下:
class Category < ActiveRecord::Base
has_many: documents
end
class Author ActiveRecord::Base
has_many :documents
end
class Document ActiveRecord::Base
belongs_to :category
belongs_to :author
end
有人碰到过这个问题吗
define_index do
# firstly, you must have at least one indexed column
indexes document.author.name :as => :author_name, :facet => true
# to add 'has' for string you crc32
# has "CRC32(string_col)", :as => :filtered_string_col
end
如果您需要搜索“has”列:
:conditions => { "string to filter on".to_crc32 }
:conditions => { "string to filter on".to_crc32 }