You should integrate Updated Apachesolr module.
Write some custom menu hook to invoke your custom function.
$query = apachesolr_current_query();
$params_query = $query->getParams();
The above two statements will help us to check our solr queryString that we have triggered from our application.
/**
* Implementation of hook_search_execute().
*/
function Custom_Function($keys = NULL, $conditions = NULL) {
$filters = isset($conditions['fq']) ? $conditions['fq'] : array();
$solrsort = isset($_GET['solrsort']) ? $_GET['solrsort'] : '';
$response = NULL;
$filt = array();
// add custom filters if you want to add few custom filters in certain conditions.
if($_GET['some key'] == 'some condition') {
$filt[] = array('name' => 'entity_type', 'value' => 'trend_tips');
}else{
$filt[] = array('name' => 'im_16_field_category', 'value' => $_GET['category']);
}
$filters = $filt;
$results = apachesolr_search_run('apachesolr', array('q' => $keys, 'fq' => $filters), $solrsort, 'search/' . arg(1), pager_find_page());
// Set name for search results
$query = apachesolr_current_query();
$params_query = $query->getParams();
if (module_hook($module, 'search_page')) {
return module_invoke($module, 'search_page', $results);
}
}
/**
* Implementation of hook_apachesolr_query_prepare().
*/
function CustomeModule_apachesolr_query_prepare(&$current_query) {
// add query filters for Style tips and trends
$current_query->addParam('fl', 'tm_image,tm_url,content');
$current_query->addParam('qf', 'tm_title');
$current_query->addParam('qf', 'tm_short_content');
$current_query->addParam('qf', 'tm_perex');
$current_query->addParam('mm', '1<-90%'); // if you write more then 1 word to search, solr search as 'OR'
$current_query->addParam('bf', 'recip(rord(created),4,5759,5759)^5.0'); // remove time dependency on search results
// remove following content types (product and page) from search
$current_query->addFilter('entity_type', 'product', true);
$current_query->addFilter('bundle', 'page', true);
$current_query->addFilter('tid', "63", true);
$current_query->addFilter('tid', "64", true);
$current_query->addParam('facet.field', 'bundle');
// add a new facet type for filter trends and tips on search results
}
Please let me know if the above codebase helped to get some grip.
Thanks