在我的IndexController上我有
public function buildAction()
{
$index = Zend_Search_Lucene::create(APPLICATION_PATH . '/indexes');
foreach ($this->pages as $p) {
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::unIndexed('page_id', $p['page_id']));
$doc->addField(Zend_Search_Lucene_Field::text('page_name', $p['page_name']));
$doc->addField(Zend_Search_Lucene_Field::text('page_headline', $p['page_headline']));
$doc->addField(Zend_Search_Lucene_Field::text('page_content', $p['page_content']));
$index->addDocument($doc);
}
$index->optimize();
$this->view->indexSize = $index->numDocs();
}
我收到错误
[Tue Jan 18 16:23:32 2011] [error] [client 127.0.0.1] PHP Notice: iconv(): Detected an illegal character in input string in /usr/share/php/libzend-framework-php/Zend/Search/Lucene/Analysis/Analyzer/Common/Text.php on line 58
[Tue Jan 18 16:23:32 2011] [error] [client 127.0.0.1] PHP Notice: iconv(): Detected an illegal character in input string in /usr/share/php/libzend-framework-php/Zend/Search/Lucene/Field.php on line 222
[Tue Jan 18 16:23:32 2011] [error] [client 127.0.0.1] PHP Notice: iconv(): Detected an illegal character in input string in /usr/share/php/libzend-framework-php/Zend/Search/Lucene/Analysis/Analyzer/Common/Text.php on line 58
[Tue Jan 18 16:23:32 2011] [error] [client 127.0.0.1] PHP Notice: iconv(): Detected an illegal character in input string in /usr/share/php/libzend-framework-php/Zend/Search/Lucene/Field.php on line 222
[Tue Jan 18 16:23:32 2011] [error] [client 127.0.0.1] PHP Notice: iconv(): Detected an illegal character in input string in /usr/share/php/libzend-framework-php/Zend/Search/Lucene/Analysis/Analyzer/Common/Text.php on line 58
[Tue Jan 18 16:23:32 2011] [error] [client 127.0.0.1] PHP Notice: iconv(): Detected an illegal character in input string in /usr/share/php/libzend-framework-php/Zend/Search/Lucene/Field.php on line 222
和变量
$this->pages
包含从维基百科复制的文本数组,我收到错误的字符 - (不是 - )和ö我得到错误(我相信)。我在Lucene foreign chars problem得到了类似的相关问题,但没有解释在哪里做什么。如果我知道该做什么以及一点点解释,我将不胜感激
更新::的iconv
iconv support enabled
iconv implementation glibc
iconv library version 2.12.1
答案 0 :(得分:10)
尝试将此添加到您的引导程序中:
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
Zend_Search_Lucene_Analysis_Analyzer::setDefault(
new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive ()
);
答案 1 :(得分:4)
除了在引导代码中添加基于文本的索引的第三个参数编码
$doc->addField(Zend_Search_Lucene_Field::text('page_name', $p['page_name'], 'UTF-8'));