2014-01-07 11:52:29 +01:00
|
|
|
ThinkingSphinx::Index.define :story, :with => :active_record do
|
|
|
|
indexes description
|
2014-09-12 17:42:22 +02:00
|
|
|
indexes short_id
|
2014-01-07 11:52:29 +01:00
|
|
|
indexes tags(:tag), :as => :tags
|
2014-09-12 17:42:22 +02:00
|
|
|
indexes title
|
|
|
|
indexes url
|
|
|
|
indexes user.username, :as => :author
|
2015-01-06 21:22:18 +01:00
|
|
|
indexes story_cache
|
2014-01-07 11:52:29 +01:00
|
|
|
|
|
|
|
has created_at, :sortable => true
|
|
|
|
has hotness, is_expired
|
2015-01-28 22:02:40 +01:00
|
|
|
has Story.score_sql, :as => :score, :type => :bigint, :sortable => true
|
2014-01-07 11:52:29 +01:00
|
|
|
|
2015-01-29 17:04:02 +01:00
|
|
|
# opts[:with] = { :id => ... } doesn't seem to work when sphinx searches on
|
|
|
|
# story_core, so give this column a different name to restrict on
|
|
|
|
has id, :as => :story_id
|
|
|
|
|
2014-01-07 11:52:29 +01:00
|
|
|
set_property :field_weights => {
|
|
|
|
:upvotes => 15,
|
|
|
|
:title => 10,
|
2015-01-06 21:22:18 +01:00
|
|
|
:story_cache => 10,
|
2014-01-07 11:52:29 +01:00
|
|
|
:tags => 5,
|
|
|
|
}
|
|
|
|
|
|
|
|
where sanitize_sql(:is_expired => false)
|
|
|
|
end
|