【发布时间】:2011-10-28 17:44:28
【问题描述】:
我阅读了this question 关于使用“LOWER”功能帮助对混合大小写列进行排序的信息。我想做一些类似但属性更复杂的事情。首先,我有一个基本的多对多关系:
class Project < ActiveRecord::Base
has_many :project_people
has_many :people, :through => :project_people
end
class ProjectPerson < ActiveRecord::Base
belongs_to :project
belongs_to :person
end
class Person < ActiveRecord::Base
has_many :project_people
has_many :projects, :through => :project_people
end
我正在使用 TS 来索引项目:
class Project
define_index
indexes name, :sortable => true
indexes [people.first_name, people.last_name], :as => :person, :sortable => true
has created_at, category_id
set_property :delta => true
end
end
这索引很好,但后来我发现了在人名中使用大写和小写字母时的问题。我尝试用以下内容替换呼叫:
has ["LOWER(people.first_name)", "LOWER(people.middle_name)", "LOWER(people.last_name)"], :as => :person, :type => :string
但我在重建索引时一直出错:
ERROR: index 'project_core': sql_range_query: Unknown column 'people.first_name' in 'field list' (DSN=mysql://...).
如何实现“LOWER(...)”功能?或者,我的实际问题。我怎样才能索引它,以便我能够按人员字段对项目进行排序并使其不区分大小写?
【问题讨论】:
标签: ruby-on-rails sorting sphinx thinking-sphinx