2014-01-07 11:52:29 +01:00
|
|
|
|
|
|
|
ThinkingSphinx::Index.define :story, :with => :active_record do
|
|
|
|
indexes url
|
|
|
|
indexes title
|
|
|
|
indexes description
|
|
|
|
indexes user.username, :as => :author
|
|
|
|
indexes tags(:tag), :as => :tags
|
|
|
|
|
|
|
|
has created_at, :sortable => true
|
|
|
|
has hotness, is_expired
|
2014-01-09 06:02:01 +01:00
|
|
|
has "(cast(upvotes as integer) - cast(downvotes as integer))",
|
2014-01-07 11:52:29 +01:00
|
|
|
:as => :score, :type => :bigint, :sortable => true
|
|
|
|
|
|
|
|
set_property :field_weights => {
|
|
|
|
:upvotes => 15,
|
|
|
|
:title => 10,
|
|
|
|
:tags => 5,
|
|
|
|
}
|
|
|
|
|
|
|
|
where sanitize_sql(:is_expired => false)
|
|
|
|
end
|