We had to create a custom search once. We created a custom module that allowed not only writing a custom query to the database but also choose the kind of amount that gets displayed. We hooked into hook_search
with the module. To give you an idea:
function yourmodule_search($op = 'search', $keys = NULL) {
switch ($op) {
//some code, basically a stripped version from what the API shows us
case 'search':
$find = do_event_search($keys); //the actual search
// Load results.
$results = array();
foreach ($find as $item) {
//iteration and adding certain elements to $resuls needned by Drupal
}
return $results;
}
}
The interessting part for you is the retrival of the search results as done by do_event_search
:
//all data comes from a queries to the database
$search_result[] = array ('link' => trim($link),
'snippet' => trim_text(i18n_get_lang() == "en" ? $row->description_en : $row->description_de),
'head' => trim_text(i18n_get_lang() == "en" ? $row->title_en : $row->title_de),
'type' => $type
);
As you can see, snippet
holds the text that should be displayed on the search pages and we select a certain $row
from a custom database. The API example shows all fields that are needed for displaying the results properly.