Zend搜索Lucene和波斯语!

时间:2011-06-03 15:29:10

标签: zend-framework utf-8 lucene persian

我的zf项目中有以下代码:

$index = Zend_Search_Lucene::open(APPLICATION_PATH . '/cache/search_index');
        $doc = new Zend_Search_Lucene_Document();

        $title = "سلام سینا xxx sad";



        $doc->addField(Zend_Search_Lucene_Field::Text('title', $title));

        $index->addDocument($doc);
        $index->commit();

        $index->optimize();
        echo "Index contains " . $index->count() . " documents.\n\n";
        $results = $index->find('xxx');
        foreach ($results as $res) {


            var_dump($res->title);
        }

当var_dump执行输出时 - > string(39)“سیناØØانxxx sad”

当我使用utf_decode时 string(25)“س ?ا ?س ? ?اxxx sad”

我怎样才能正确解码! :(

我已经在这个SOF问题中使用了解决方案 - > lucene encoding problem in zend framework

但不起作用,并添加了关于iconv的通知错误!

plz help :)。

1 个答案:

答案 0 :(得分:0)

通过此代码修复:

$index = Zend_Search_Lucene::open(APPLICATION_PATH . '/cache/search_index');
    $doc = new Zend_Search_Lucene_Document();

    $title = "سلام سینا xxx sad";



    $doc->addField(Zend_Search_Lucene_Field::Text('title', $title,"UTF8"));

    $index->addDocument($doc);
    $index->commit();

    $index->optimize();
    echo "Index contains " . $index->count() . " documents.\n\n";



    var_dump($index->getDocument(9));

    echo "Search";
     $results = $index->find('سینا');
   foreach ($results as $res) {


        var_dump($res->title);
    }

    die(1);