Diff
Modified: trunk/app/models/blob.rb (2212 => 2213)
--- trunk/app/models/blob.rb 2009-06-09 12:50:08 UTC (rev 2212)
+++ trunk/app/models/blob.rb 2009-06-09 13:16:58 UTC (rev 2213)
@@ -25,7 +25,8 @@
acts_as_attributor
acts_as_attributable
- acts_as_solr(:fields => [:title, :local_name, :body, :type, :uploader],
+ acts_as_solr(:fields => [:title, :local_name, :body, :kind, :uploader],
+ :boost => "search_boost",
:include => [ :comments ]) if Conf.solr_enable
belongs_to :content_blob
@@ -46,4 +47,17 @@
def type
content_type.title
end
+
+ alias_method :kind, :type
+
+ def search_boost
+
+ # initial boost depends on viewings count
+ boost = contribution.viewings_count
+
+ # penalty for no description
+ boost = 0 if body.nil? || body.empty?
+
+ boost
+ end
end
Modified: trunk/app/models/pack.rb (2212 => 2213)
--- trunk/app/models/pack.rb 2009-06-09 12:50:08 UTC (rev 2212)
+++ trunk/app/models/pack.rb 2009-06-09 13:16:58 UTC (rev 2213)
@@ -27,6 +27,7 @@
format_attribute :description
acts_as_solr(:fields => [ :title, :description, :contributor_name, :tag_list ],
+ :boost => "search_boost",
:include => [ :comments ]) if Conf.solr_enable
has_many :contributable_entries,
@@ -892,5 +893,14 @@
return item_data
end
-
+ def search_boost
+
+ # initial boost depends on viewings count
+ boost = contribution.viewings_count
+
+ # penalty for no description
+ boost = 0 if description.nil? || description.empty?
+
+ boost
+ end
end
Modified: trunk/app/models/workflow.rb (2212 => 2213)
--- trunk/app/models/workflow.rb 2009-06-09 12:50:08 UTC (rev 2212)
+++ trunk/app/models/workflow.rb 2009-06-09 13:16:58 UTC (rev 2213)
@@ -85,6 +85,7 @@
non_versioned_columns.push("license", "tag_list", "body_html")
acts_as_solr(:fields => [ :title, :body, :tag_list, :contributor_name, :kind, :get_all_search_terms ],
+ :boost => "search_boost",
:include => [ :comments ]) if Conf.solr_enable
acts_as_runnable
@@ -258,4 +259,15 @@
end
alias_method :kind, :type
+
+ def search_boost
+
+ # initial boost depends on viewings count
+ boost = contribution.viewings_count
+
+ # penalty for no description
+ boost = 0 if body.nil? || body.empty?
+
+ boost
+ end
end
Modified: trunk/vendor/plugins/acts_as_solr/lib/instance_methods.rb (2212 => 2213)
--- trunk/vendor/plugins/acts_as_solr/lib/instance_methods.rb 2009-06-09 12:50:08 UTC (rev 2212)
+++ trunk/vendor/plugins/acts_as_solr/lib/instance_methods.rb 2009-06-09 13:16:58 UTC (rev 2213)
@@ -107,7 +107,9 @@
end
def validate_boost(boost)
- if boost.class != Float || boost < 0
+ if boost.class == String
+ return eval(boost)
+ elsif boost.class != Float || boost < 0
logger.warn "The boost value has to be a float and posisive, but got #{boost}. Using default boost value."
return solr_configuration[:default_boost]
end
@@ -136,4 +138,4 @@
end
end
-end
\ No newline at end of file
+end