tags:

views:

209

answers:

1

I was trying to do do a boolean search 'sname:'.$user->name.' OR sname:xxxxxx; , i am not getting any results where as sname:xxxxxx; works fine. i even added mm=1 with the query modify hook. can somebody guide me how i can accomplish this.

Here is my code.....

$keys = "";
$filters = 'sname:'.$user->name.' OR sname:xxxxxx;
//print($filters);
$solrsort = variable_get('apachesolr_search_taxonomy_sort', 'created desc');
$page = isset($_GET['page']) ? $_GET['page'] : 0;
$_GET['retain-filters'] = 1;

try {
//stolen from search.module (search_data)
$data = apachesolr_search_execute($keys, $filters, $solrsort, 'search/apachesolr_search', $page);
$results = theme('search_results', $data, $type);
} catch (Exception $e){
watchdog('apachesolr', t('Error running search'));
}

function reports_apachesolr_modify_query(&$query, &$params, $caller) {
// I only want to see articles by the admin!
$params['mm'] = 1;
}

Adv thanks.

+1  A: 

The $user object is not available in some places, so it depends where you are calling it from. You need to invoke it globally. Add the following to the top of your code.

$keys = "";
global $user; //Add this line
$filters = 'sname:'.$user->name.' OR sname:xxxxxx';

Also note that you are missing a closing quotation mark after the xxxxxx. I added it in the above code.

theunraveler
thank u for your answer, but the problem is not with the user object, the problem is with the dismax query builder of apache solr.
pmarreddy
Aww bummer. We'll I'm afraid I don't know much about Apache Solr syntax, so I can't really help.
theunraveler