journalduhacker/app/indices/story_index.rb
joshua stein 9e8b89be1c cast story.{upvotes,downvotes} to signed on mysql, integer on postgres
old mysql doesn't support 'cast(1 as integer)', but new/mariadb does

postgres doesn't support 'cast(1 as signed)'

should fix #145
2014-10-06 14:07:53 -05:00

23 lines
579 B
Ruby

ThinkingSphinx::Index.define :story, :with => :active_record do
indexes description
indexes short_id
indexes tags(:tag), :as => :tags
indexes title
indexes url
indexes user.username, :as => :author
has created_at, :sortable => true
has hotness, is_expired
has "(CAST(upvotes as #{Story.votes_cast_type}) - " <<
"CAST(downvotes as #{Story.votes_cast_type}))", :as => :score,
:type => :bigint, :sortable => true
set_property :field_weights => {
:upvotes => 15,
:title => 10,
:tags => 5,
}
where sanitize_sql(:is_expired => false)
end