M
M
Maxim Maximov2015-08-19 05:32:41
Zend Framework
Maxim Maximov, 2015-08-19 05:32:41

Why is the zf2 lucene backlight not working?

Hello!
Searching with Lucene:

setlocale(LC_ALL, 'ru_RU.UTF-8');
            Lucene\Analysis\Analyzer\Analyzer::setDefault(
                new Lucene\Analysis\Analyzer\Common\Utf8\CaseInsensitive());
            $index = Lucene\Lucene::open($searchIndexLocation);      
            $searchResults = $index->find($validatedQuery['searchQuery']);

Then the words for which the search was performed should be highlighted:
\ZendSearch\Lucene\Search\QueryParser::setDefaultEncoding('UTF-8');
        $doc = Html::loadHTML($high, false, $defaultEncoding = 'UTF-8');
        $doc->highlight($validatedQuery['searchQuery'], $colour = '#66ffff');     
        $highlightedHTML=$doc->getHTMLBody();

Everything works fine with English text, but Russian words are either not highlighted at all, or individual letters are highlighted in other words that do not match the request. Moreover, if the request begins with a capital Russian letter, then the search does not work at all. What can be wrong? Thank you.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question