function apachesolr_panels_search_execute in Apache Solr Panels 7
Same name and namespace in other branches
- 6.3 apachesolr_panels.module \apachesolr_panels_search_execute()
- 6 apachesolr_panels.module \apachesolr_panels_search_execute()
Execute a Solr search.
Using hook_search() would make this module a first-class search module alongside Apache Solr Search, which we don't want. Instead, we execute the search directly and imitate what the core Search module does.
See also
1 call to apachesolr_panels_search_execute()
- apachesolr_panels_apachesolr_result_content_type_render in plugins/
content_types/ apachesolr_result.inc - Render the search results.
File
- ./
apachesolr_panels.module, line 109 - Integrates Apache Solr Search with Panels.
Code
function apachesolr_panels_search_execute($search) {
// Store information about the search for use in other panes.
apachesolr_panels_static_search_cache($search);
$results = NULL;
try {
$solr = apachesolr_get_solr($search['env_id']);
$results = apachesolr_search_run('apachesolr', array_filter(array(
'q' => $search['keys'],
'fq' => $search['filters'],
'rows' => $search['rows'],
)), $search['sort'], $search['path'], $search['page'], $solr);
} catch (Exception $e) {
watchdog('Apache Solr', nl2br(check_plain($e
->getMessage())), NULL, WATCHDOG_ERROR);
apachesolr_failure(t('Solr search'), $search['keys']);
}
// Imitate search_data() to present the results as Apache Solr Search would.
if (is_array($results) && count($results)) {
if (module_hook('apachesolr_search', 'search_page')) {
return module_invoke('apachesolr_search', 'search_page', $results);
}
else {
return theme('search_results', array(
'results' => $results,
'module' => 'apachesolr_search',
));
}
}
}