0

This piece of code from my controller:

    $index = new Zend_Search_Lucene(Yii::getPathOfAlias('application.' . $this->_indexFiles));
    $results = $index->find($term);
    $query = Zend_Search_Lucene_Search_QueryParser::parse($term,'utf-8');

Then I tried to highlight my result in view file:

echo $query->highlightMatches($result->method, 'utf-8');

But I got exception in ZendSearch/Lucene/Analysis/Analyzer/Common/Utf8.php(77)

iconv(): Detected an illegal character in input string

Question is what I can do to solve this problem.

Insane Skull
  • 9,220
  • 9
  • 44
  • 63
StalkAlex
  • 743
  • 7
  • 16

1 Answers1

0

I do some research. Problem was in ZendSearch/Lucene/Document/Html.php highlightExtended function.

$analyzer->tokenize($wordString);

Tokenize function accepts encoding as the second parameter, but in the line above I think it was missed.

Code:

public function tokenize($data, $encoding = '')
    {
        $this->setInput($data, $encoding);
        $tokenList = array();
        while (($nextToken = $this->nextToken()) !== null) {
            $tokenList[] = $nextToken;
        }
        return $tokenList;
    }

So iconv was called with empty string as encoding parameter. To solve my problem I just did

 public function tokenize($data, $encoding = 'UTF-8')

And everything became ok.

StalkAlex
  • 743
  • 7
  • 16