来自我的控制器的这段代码:
$index = new Zend_Search_Lucene(Yii::getPathOfAlias('application.' . $this->_indexFiles));
$results = $index->find($term);
$query = Zend_Search_Lucene_Search_QueryParser::parse($term,'utf-8');
然后我尝试在视图文件中突出显示我的结果:
echo $query->highlightMatches($result->method, 'utf-8');
但我在ZendSearch / Lucene / Analysis / Analyzer / Common / Utf8.php(77)中得到例外
iconv(): Detected an illegal character in input string
问题是我可以做些什么来解决这个问题。
答案 0 :(得分:0)
我做了一些研究。问题出在ZendSearch / Lucene / Document / Html.php highlightExtended 函数中。
$analyzer->tokenize($wordString);
Tokenize函数接受编码作为第二个参数,但在上面的行中我认为它已被遗漏。
代码:
public function tokenize($data, $encoding = '')
{
$this->setInput($data, $encoding);
$tokenList = array();
while (($nextToken = $this->nextToken()) !== null) {
$tokenList[] = $nextToken;
}
return $tokenList;
}
因此使用空字符串作为编码参数调用iconv。为了解决我的问题,我刚刚做了
public function tokenize($data, $encoding = 'UTF-8')
一切都变好了。