开发者

Zend Search Lucene And Persian Language !

i have the following code in my zf project :

$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);
        }

when var_dump 开发者_如何学Goperforms output -> string(39) "سینا جان xxx sad"

when i user utf_decode string(25) "س�?ا�? س�?�?ا xxx sad"

how can i decode that correctly ! :(?

i already used the solution in this SOF quesion -> lucene encoding problem in zend framework

but not works and a notice error added about iconv !

plz help :)


Fixed by this code:

$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); 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜