I'm using Search API with a SOLR server. Is there anyway to boost newer content? My goal is to make newer content more likely to return in search results than older.

On a previous drupal site, using only apache solr, there was a 'Result Biasing' option that allowed you to change the scoring of 'Most recently created'. This was described as "This setting will change the result scoring so that nodes created more recently may appear before those with higher keyword matching."

I'm trying to find a way to achieve this same function using Search API and SOLR.

Comments

rovo’s picture

Issue summary: View changes
drunken monkey’s picture

No, sorry, there currently isn't any ready-made functionality to do that in the module. For now, you'd need to write some custom code, specifically a hook_search_api_solr_query_alter() implementation, to add the necessary boosting parameter to the Solr request yourself.

However, it would probably be not too hard to add such a feature for general use in the future, once someone has the time to work on this.

rovo’s picture

Status: Active » Fixed

Thanks!

I was able to accomplish boosting more recently created nodes, by creating this tiny module. Maybe someone else will find it of use.

function search_api_date_boost_search_api_solr_query_alter(&$call_args, SearchApiQueryInterface $query) {
  // Boost the relevance of the created date field
  $call_args['params']['bf'][] = 'recip(ms(NOW/HOUR,ds_field_display_date),3.16e-11,1,1)^40.0';
}

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.