1

我试图做一个布尔搜索'sname:'.$user->name。' 或姓名:xxxxxx;,我没有得到任何结果,如 sname:xxxxxx; 工作正常。我什至在查询修改钩子中添加了 mm=1。有人可以指导我如何做到这一点。

这是我的代码......

$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;
}

进阶谢谢。

4

2 回答 2

1

$user 对象在某些地方不可用,因此这取决于您从哪里调用它。您需要全局调用它。将以下内容添加到代码的顶部。

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

另请注意,您在 xxxxxx 之后缺少右引号。我在上面的代码中添加了它。

于 2009-11-02T18:02:01.987 回答
0

Did you try removing the second sname:?? My SOLR filters look like:

(fname:carrie OR carol) 
AND
(lname:miller OR jones)
于 2011-07-08T18:39:13.373 回答