|
Revision 321, 1.0 kB
(checked in by jk, 8 months ago)
|
drb somewhat works
|
| Line | |
|---|
| 1 |
# common base class for Content and SpecialContent |
|---|
| 2 |
class ContentBase < ActiveRecord::Base |
|---|
| 3 |
set_table_name 'contents' |
|---|
| 4 |
|
|---|
| 5 |
# a higher boost means more importance for the field --> documents having a |
|---|
| 6 |
# match in a field with a higher boost value will be ranked higher |
|---|
| 7 |
# |
|---|
| 8 |
# we use the store_class_name flag to be able to retrieve model instances when |
|---|
| 9 |
# searching multiple indexes at once. |
|---|
| 10 |
# the contents of the description field are stored in the index for running |
|---|
| 11 |
# 'more like this' queries to find other content instances with similar |
|---|
| 12 |
# descriptions |
|---|
| 13 |
acts_as_ferret( :fields => { :comment_count => { :index => :untokenized }, |
|---|
| 14 |
:title => { :boost => :title_boost }, |
|---|
| 15 |
:description => { :boost => 1, :store => :yes }, |
|---|
| 16 |
:special => {} }, |
|---|
| 17 |
:boost => :record_boost) |
|---|
| 18 |
|
|---|
| 19 |
def comment_count; 0 end |
|---|
| 20 |
|
|---|
| 21 |
attr_accessor :record_boost |
|---|
| 22 |
attr_writer :title_boost |
|---|
| 23 |
def title_boost |
|---|
| 24 |
@title_boost || 2 |
|---|
| 25 |
end |
|---|
| 26 |
end |
|---|
| 27 |
|
|---|
| 28 |
|
|---|