2013-12-16 1 views
0

제발 영어로 말해줘, 프랑스어 해요!스핑크스 검색 - 불린으로 검색

내 웹 사이트에서 스핑크스 검색 기능을 통합하고 싶지만 한두 가지 질문이 있습니다!

그래서, 난 (CodeIgniter를 포함) 옷의 전자 상거래 웹 사이트를 가지고 모든 문서에서는 이러한 PARAMS이 : 아이디, 제목, categoryName이, 크기, 브랜드, 설명으로 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"]) ); 
} 

감사합니다.

답변

1

구성 파일에서 부울을 속성으로 정의해야합니다.

그런 다음 SetFilter 기능을 사용할 수 있습니다. 글쎄, 그 (것)들에 여과하십시오 :