【发布时间】:2017-08-29 11:21:49
【问题描述】:
我有一个多态关联的笔记模型,如下所示
incident has one symptom -> (note model)
incident has many comments -> (note model)
和
我想为注释类型为“症状”的注释进行中缀索引,并希望为注释类型为“注释”的注释进行前缀索引
我已经在 Sphinx 索引中尝试了以下代码
ThinkingSphinx::Index.define(:incident, DEFAULT_INDEX_OPTIONS.merge(name: "incident_prefix"), &Searchable.beetilable_index('Incident', index_count: incident_index_count, index_id: i) {
set_property :min_infix_length => 3
indexes notes.note, :as => :notes, :source => :query
notes.where(note_type: "Symptom")
}
ThinkingSphinx::Index.define(:incident, DEFAULT_INDEX_OPTIONS.merge(name: "incident_infix"), &Searchable.beetilable_index('Incident', index_count: incident_index_count, index_id: i) {
set_property :min_prefix_length => 3
indexes notes.note, :as => :notes, :source => :query
notes.where.not(note_type: "Symptom")
}
上面的代码只是使用 INFIX 选项进行索引,而忽略了 PREFIX 选项。我猜我的 where 条件有问题,有人可以告诉我实现这一点的方法吗?
【问题讨论】:
标签: ruby-on-rails sphinx thinking-sphinx