2012-12-10 31 views
0

獅身人面像0.9.9已經配置了的MySql工作。
我最近注意到,獅身人面像不適用於包含任何多次出現的搜索字詞<>字符。搜索在獅身人面像0.9.9失敗多< or >

工作PHP代碼:

// Initialize SphinxClient class object 
$cl = new SphinxClient(); 
// Set the server and port 
$cl->SetServer ("127.0.0.1", 9313); 

// Initialize prefixed query 
$query_prefix = ''; 
// Set the limit 
$cl->SetLimits((int)$offset, (int)$count); 
// Set the match mode 
$cl->setMatchMode(SPH_MATCH_EXTENDED); 
// Set the ranking mode 
$cl->setRankingMode(SPH_RANK_WORDCOUNT); 
// Set sorting 
$cl->SetSortMode(SPH_SORT_EXTENDED,'@relevance DESC, updated_date DESC'); 

$query_main = '@(name,description)'; 

// Initialize the search index 
$search_index = 'index_common'; 

$search_text = $cl->EscapeString($search_text); 

// Run the search query 
$resp = $cl->Query($query_prefix . '('. $query_main . '"^' . $search_text . '$" | "' . 
    $search_text . '" | (' . $search_text . ') | "' 
    . $search_text . '"/1 | (' . $search_text_wild . ')) ' ,$search_index); 

如果我輸入類似 「>>」 的搜索項中沒有報價就產生下面的查詢:

(@(name,description)"^>>$" | ">>" | (>>) | ">>"/1 | (*>>*)) 

,不給任何迴應比如在系統中找不到搜索字詞時。這種情況發生在<>多次出現的情況。

這是一個已知問題獅身人面像還是有辦法克服(使獅身人面像工作正常的這種特殊情況下)?

回答

1

< <被用作嚴格的命令操作符 - 我認爲還有非官方的>>語法。

所以這可能會導致問題。你可以試着逃避它們,我猜EscapeString不會去做。

但請記住,除非<和>在您的charset表中,否則它們將永遠無法匹配。

(此外,當你說你沒有迴應,一定要檢查$cl->getLastError() !!