journalduhacker/app/indices/story_index.rb

27 lines
709 B
Ruby
Raw Normal View History

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
indexes story_cache
2014-01-07 11:52:29 +01:00
has created_at, :sortable => true
has hotness, is_expired
has Story.score_sql, :as => :score, :type => :bigint, :sortable => true
2014-01-07 11:52:29 +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,
:story_cache => 10,
2014-01-07 11:52:29 +01:00
:tags => 5,
}
where sanitize_sql(:is_expired => false)
end