5

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 performs 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 :)

4
  • 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? Dec 30, 2014 at 7:29
  • @SamiraKhorshidi lotf kon finglish nanevis inja ... lotfan biain to gmail ... codeton ro bayad bebinam miandashti@gmail.com Dec 30, 2014 at 18:54
  • mamnun,moshkel hal shod inam rahe hal :) stackoverflow.com/questions/5834861/… Dec 31, 2014 at 7:30
  • @SamiraKhorshidi good luck Dec 31, 2014 at 7:47

1 Answer 1

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.