0
請原諒我的英語,我是法國人!斯芬克斯搜索 - 用布爾值搜索
我想將Sphinx搜索整合到我的網站上,但我有一兩個問題!
所以,我有一個服裝電子商務網站(含笨)和每一篇文章都有那些PARAMS:ID,標題,類別名稱,規模,品牌,說明,請將isDeleted,isSold等
當我創造用布爾搜索,它被忽略!那麼你能否告訴我如何過濾刪除和出售的文章(isDeleted和isSold字段)?
這裏我的代碼
function sphinx_search($fields, $order_by, $order_order, $position, $offset, $limit){
$CI =& get_instance();
$CI->load->library('SphinxClient');
$ids = array();
$CI->sphinxclient->SetServer("localhost" , 9312);
$CI->sphinxclient->SetMatchMode(SPH_MATCH_ANY);
$CI->sphinxclient->SetFieldWeights(array('title' => 300, 'categoryName' => 200, 'size' => 150, 'brand' => 100, 'description' => 30));
$CI->sphinxclient->SetLimits($offset, $limit);
$CI->sphinxclient->SetSortMode(SPH_SORT_EXTENDED, $order_by.' '.$order_order);
if (!empty($position)) {
$CI->sphinxclient->SetGeoAnchor('latitude', 'longitude', (float) deg2rad($position['latitude']), (float) deg2rad($position['longitude']));
$CI->sphinxclient->setSelect("*, IF(@geodist<50000,30,0)+IF(@geodist<20000,80,0)+IF(@geodist<5000,150,0)[email protected] AS performance");
}
$query='';
foreach ($fields as $key => $value) {
if ($key == 'q') {
$query .= ' '.$value.' ';
} else {
$query .= ' @'.$key.' '.$value.' ';
}
}
$result = $CI->sphinxclient->Query($query, 'catalog');
if ($result === false)
var_dump('[SPHINX]Query failed: ' . $CI->sphinxclient->GetLastError());
elseif ($CI->sphinxclient->GetLastWarning())
var_dump('[SPHINX]WARNING: ' . $CI->sphinxclient->GetLastWarning());
if (!empty($result["matches"])){
foreach ($result["matches"] as $doc => $docinfo)
$ids[] = $doc;
} else {
return false;
}
return array('ids' => $ids, 'total' => $result['total'], 'docs' => count($result["matches"]) );
}
感謝。