Drupal + Solr, boost result based on custom node weight I use Drupal 6 with the ApacheSolr search module.

On my website, all visitors can flag any node with a yes/no answer to the question "Did you find what you were looking for?". Based on those answers, I calculate a custom ranking score for each node which is stored in a separate DB table.

Now I would like to include this score when sorting/boosting the search results in Solr, so that those nodes with the best relevancy / score come out on top.

Can it be accomplished with hook_apachesolr_prepare_query()?

All suggestions are welcome :)
To provide the score as a sort option add it in the prepare_query hook:

function mymodule_apachesolr_prepare_query(&amp;$query, &amp;$params, $caller) {
  $query-&gt;set_available_sort('field_score', array('title' =&gt; t('Score'), 'default' =&gt; 'desc'));
}


To boost by it you'll need to either:


Go to Site settings -> Apachesolr -> Search fields and if the score field appears there give it a value bigger than all the other fields to make it the most relevant.
If the field doesn't appear (due to the type it might not appear) or you want more control (like calculate the boost value on every query) you can add the boost in the modify_query hook with something like this: $params['qf'][] = 'field_score^10';.