【问题标题】:Zend Search Lucene And Persian Language !Zend 搜索 Lucene 和波斯语!
【发布时间】:2011-06-03 15:29:09
【问题描述】:

我的 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 伤心"

当我使用 utf_decode string(25) "س�?ا�? س�?�?ا xxx 伤心"

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

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

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

请帮助:)

【问题讨论】:

  • salam,man data ro az database miaram va ghabl az index kardanesh dorost neshun mide Vali vaghti documentam ro index mikonam va y reshte e farsi search mikonam natije ii nemibinam,idea ii darin?
  • @SamiraKhorshidi lotf kon finglish nanevis inja ... lotfan biain to gmail ... codeton ro bayad bebinam miandashti@gmail.com
  • mamnun,moshkel hal shod inam rahe hal :) stackoverflow.com/questions/5834861/…
  • @SamiraKhorshidi 祝你好运

标签: zend-framework utf-8 lucene persian


【解决方案1】:

由此代码修复:

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

【讨论】:

    猜你喜欢
    • 2010-11-06
    • 1970-01-01
    • 2011-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-26
    • 1970-01-01
    相关资源
    最近更新 更多