function apachesolr_multisitesearch_process_response in Apache Solr Multisite Search 6.2
Same name and namespace in other branches
- 6 apachesolr_multisitesearch.module \apachesolr_multisitesearch_process_response()
1 call to apachesolr_multisitesearch_process_response()
- apachesolr_multisitesearch_execute in ./apachesolr_multisitesearch.module
- Execute a search results based on keyword, filter, and sort strings.
File
- ./apachesolr_multisitesearch.module, line 236
- Provides a multi-site search implementation for use with the Apache Solr module
Code
function apachesolr_multisitesearch_process_response($response, $query, $params) {
$results = array();
$hl_fl = is_null($params['hl.fl']) ? 'body' : $params['hl.fl'];
$total = $response->response->numFound;
apachesolr_pager_init($total, $params['rows']);
if ($total > 0) {
foreach ($response->response->docs as $doc) {
$extra = array();
if (isset($response->highlighting->{$doc->id}->{$hl_fl})) {
$snippet = theme('apachesolr_search_snippets', $doc, $response->highlighting->{$doc->id}->{$hl_fl});
}
elseif (isset($doc->teaser)) {
$snippet = theme('apachesolr_search_snippets', $doc, array(
truncate_utf8($doc->teaser, 256, TRUE),
));
}
else {
$snippet = '';
}
if (!isset($doc->body)) {
$doc->body = $snippet;
}
$doc->created = strtotime($doc->created);
$doc->changed = strtotime($doc->changed);
drupal_alter('apachesolr_search_result', $doc);
$extra[] = format_plural($doc->comment_count, '1 comment', '@count comments');
$results[] = array(
'link' => $doc->url,
'type' => $doc->type_name,
'title' => htmlspecialchars_decode($doc->title, ENT_QUOTES),
'user' => theme('apachesolr_multisitesearch_username', $doc),
'date' => $doc->created,
'node' => $doc,
'extra' => $extra,
'score' => $doc->score,
'snippet' => $snippet,
);
}
foreach (module_implements('apachesolr_process_results') as $module) {
$function = $module . '_apachesolr_process_results';
$function($results, 'apachesolr_multisitesearch');
}
}
return $results;
}