Lucene coding issue in zend framework

i use the lucene search indexer.

It works fine in English, but I use Persian on my site and it cannot index this language

e.g. "لام

I use this code to create a document:

public function __construct($class, $key, $title,$contents, $summary, $createdBy, $dateCreated)
    {
        $this->addField(Zend_Search_Lucene_Field::Keyword('docRef', "$class:$key"));
        $this->addField(Zend_Search_Lucene_Field::UnIndexed('class', $class));
        $this->addField(Zend_Search_Lucene_Field::UnIndexed('key', $key));
        $this->addField(Zend_Search_Lucene_Field::Keyword('title', $title ,'utf-8'));
        $this->addField(Zend_Search_Lucene_Field::unStored('contents', $contents , 'UTF-8'));
        $this->addField(Zend_Search_Lucene_Field::text('summary', $summary , 'UTF-8'));
        $this->addField(Zend_Search_Lucene_Field::Keyword('dateCreated', $dateCreated));
    }
+1
source share
2 answers

Add this (best boot file)

    Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
    Zend_Search_Lucene_Analysis_Analyzer::setDefault(
        new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive ()
    );
+6
source

I had the same problem that @afsane reported, and then I tried the solution provided by @ArneRie. This solved my problem, although after some testing, I realized that the first line is not needed (at least in my current setup).

, , , , :

Zend_Search_Lucene_Analysis_Analyzer::setDefault(
    new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive());
$index = Zend_Search_Lucene::create('/path/to/my/index');

, .

+1