A new feature in Drupal 7 is hook_module_implements_alter
You could use that to fork/override the node_search_execute (hook_search_execute) function in your own module.
e.g:
/**
* Implements hook_module_implements_alter
*/
function mymodule_module_implements_alter(&$implementations, $hook) {
if ($hook == 'search_execute') {
// Sorry node module, no hook_search_execute for you
unset($implementations['node']);
}
}
and then implement your own copy
/**
* Implements hook_search_execute
* Override core node_search_execute here with custom implementation
* Basically a clone of node_search_execute, but with limit variable available
* See mymodule_module_implements_alter
*/
function mymodule_search_execute($keys = NULL, $conditions = NULL) {
// Add new limit conf variable
$limit = variable_get('search_result_limit', 10);
// Build matching conditions
$query = db_select('search_index', 'i', array('target' => 'slave'))->extend('SearchQuery')->extend('PagerDefault');
$query->join('node', 'n', 'n.nid = i.sid');
$query
->condition('n.status', 1)
->addTag('node_access')
->searchExpression($keys, 'node');
// Insert special keywords.
$query->setOption('type', 'n.type');
$query->setOption('language', 'n.language');
if ($query->setOption('term', 'ti.tid')) {
$query->join('taxonomy_index', 'ti', 'n.nid = ti.nid');
}
// Only continue if the first pass query matches.
if (!$query->executeFirstPass()) {
return array();
}
// Add the ranking expressions.
_node_rankings($query);
// Load results, use limit variable
$find = $query
->limit($limit)
->execute();
$results = array();
foreach ($find as $item) {
// Render the node.
$node = node_load($item->sid);
$build = node_view($node, 'search_result');
unset($build['#theme']);
$node->rendered = drupal_render($build);
// Fetch comments for snippet.
$node->rendered .= ' ' . module_invoke('comment', 'node_update_index', $node);
$extra = module_invoke_all('node_search_result', $node);
$uri = entity_uri('node', $node);
$results[] = array(
'link' => url($uri['path'], array_merge($uri['options'], array('absolute' => TRUE))),
'type' => check_plain(node_type_get_name($node)),
'title' => $node->title,
'user' => theme('username', array('account' => $node)),
'date' => $node->changed,
'node' => $node,
'extra' => $extra,
'score' => $item->calculated_score,
'snippet' => search_excerpt($keys, $node->rendered),
'language' => entity_language('node', $node),
);
}
return $results;
}