To alter the query itself, try [hook_search_api_query_alter][1] (for search api) or [hook_search_execute][2] for the core search


  [1]: http://drupalcontrib.org/api/drupal/contributions!search_api!search_api.api.php/function/hook_search_api_query_alter/7
  [2]: https://api.drupal.org/api/drupal/modules%21search%21search.api.php/function/hook_search_execute/7