On the Apache Solr Wiki under the rord function:

WARNING: as of Solr 1.4, ord() and rord() can cause excess memory use since they must use a FieldCache entry at the top level reader, while sorting and function queries now use entries at the segment level. Hence sorting or using a different function query, in addition to ord()/rord() will double memory use.

The date boosting function can be replaced according to the wiki so we should do this so we can reduce the memory footprint required to run queries as well as speeding them up.

http://wiki.apache.org/solr/FunctionQuery#Date_Boosting

In the file apachesolr_views.query.inc this would probably look something like:

// date_settings
$date_settings = variable_get('apachesolr_search_date_boost', '3.16e-11:1');
list($date_steepness, $date_boost) = explode(':', $date_settings);
if (!empty($date_boost)) {
  $values = array($date_steepness, $total, $total, $date_boost);
  $this->add_boost_function("recip(ms(NOW/HOUR,created),%f,%d,%d)^%f", $values);
}
There are approximately 3.16e10 milliseconds in a year, so one can scale dates to fractions of a year with the inverse, or 3.16e-11. Thus the function recip(ms(NOW,mydatefield),3.16e-11,1,1) will yield values near 1 for very recent documents, 1/2 for documents a year old, 1/3 for documents two years old, etc. Be careful to not use this function for dates more than one year in the future or the values will be negative.

Comments

timhilliard’s picture

Issue summary: View changes

added file that needs to be changed to message

timhilliard’s picture

Issue summary: View changes

fixed spelling mistake

kenorb’s picture

Status: Active » Closed (outdated)

Version 6.x is no longer supported due to Drupal 6 End of Life. For Drupal 8.x, use Search API Solr Searchinstead.