OR Search Relevance Ranking

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
T1TAN23@drupal.org's picture

I need some help figuring out the best way to implement keyword relevance ranking in my search results set when conducting an OR search on node content. I have implemented a theme_search_form_alter to build a custom search_block_form and I have everything working with the exception of getting the results to rank properly based on keywords entered into the search_block_form.

The site I am working on is for a medical supply company and the client wants err NEEDS the search results to be ranked according to relevance. For example...

If you search for latex gloves you get about 5 pages of results because of the OR search, but the results that have both Latex and Gloves in the node title or body are sprinkled throughout the rest of the results that only have latex or gloves. The end goal would be to have all the results containing both latex and gloves ranked higher than those results that have only latex or gloves.

The site isn't quite finished yet as the client still has quite a bit of content to add, but all the taxonomy and end product pages are in, so searching on any other keywords should yield at least some results and if you want to see what I am talking about the site is here

If it helps here is the code I used to implement the theme_search_form_alter

function xxx_search_form_alter($form_id, &$form) {
  ##drupal_set_message('<pre>' . print_r($form_id, TRUE) . '</pre>');
  switch ($form_id){
    case 'search_block_form':
      $form['#action'] = url('search/node');
     $form['type-product']['#value'] = 'product';
      $form['type-product']['#type'] = 'hidden';
      $form['type-product']['#name'] = 'type[product]';
      $form['#id'] = 'search-form';
      $form['form_id']['#id'] = 'edit-search-form';
      $form['form_id']['#value'] = 'search_form';
      $form['#token'] = 'search_form';
      $form['form_token']['#default_value'] = drupal_get_token('search_form');
      $form['basic']['inline']['#prefix'] = '<div id=\'search-inner\'>';
      $form['basic']['inline']['or'] = $form['search_block_form_keys'];
      $form['basic']['inline']['or']['#class'] = 'form-text';
      unset($form['search_block_form_keys']);
      $form['basic']['inline']['submit'] = $form['submit'];
      unset($form['submit']);
      $form['basic']['inline']['submit']['#suffix'] = '</div>';
      $form['type[product]'] = array(
        '#prefix' => '<div id="search-type">',
        '#type' => 'radios',
        '#default_value' => 'product',
        '#options' => array('0' => t('Entire site'), 'product' => t('Entire Catalog')),
        '#suffix' => '</div>',
      );
      $form['basic']['inline']['submit']['#value'] = 'GO';
      ##drupal_set_message('<pre>' . print_r($form, TRUE) . '</pre>');   
      break;
    case 'search_form':
      $form['type-product']['#value'] = 'product';
      $form['type-product']['#type'] = 'hidden';
      $form['type-product']['#name'] = 'type[product]';
      break;
  }
}

So I guess my question with all this is, can I use theme_db_rewrite_sql to inject the necessary SQL to get the results ordered the way the client wants or is there a patch or module already out there that will help accomplish this task?

I have been pulling my hair out for weeks trying to figure this out and then I stumbled across this group and thought to myself, "self" cuz that's what I call myself when I am thinking to myself, so I thought... "self, this group is going to save you from any further hair loss, because they know more about the drupal search inner workings than any other place on the web"

Any help would be greatly appreciated and hopefully some day in the near future I can return the hospitable favor.

Thanks to any and all,
~T1TAN23~