teamtnt / tntsearch

A fully featured full text search engine written in PHP
https://tnt.studio/solving-the-search-problem-with-laravel-and-tntsearch
MIT License
3.09k stars 292 forks source link

How highlight finding part with morphology? (as for Russian search) #124

Open lgXenos opened 6 years ago

lgXenos commented 6 years ago

Hi I'm glad, that TNTSearch can use russian morphology and match of words variations But... When I'm try highlight finding part - I'm get empty string image When I'm open some empty results, I'm find another variations of my word. And TNT-search found exactly this words! Not full match. image

So... Can I'm highlight finding part with morphology and with all match of words variations, that TNTSearch know?

$findThis = 'лестница';

$fullText = 'царь спускается по лестнице. но никто не видит лестницы. в остальном лестницу уже унесли.';
echo "<br><br><b>fullText:</b> $fullText<br> <u>snippet result</u>: " . $this->tnt->snippet($findThis, $fullText, 50);

$fullText = 'а всё, что было нужно - это наша лестница.';
echo "<br><br><b>fullText:</b> $fullText<br> <u>snippet result</u>: " . $this->tnt->snippet($findThis, $fullText, 50);

$fullText = 'царь спускается по лестнице. но никто не видит лестницы. в остальном лестницу уже унесли. а всё, что было нужно - это наша лестница.';
echo "<br><br><b>fullText:</b> $fullText<br> <u>snippet result</u>: " . $this->tnt->snippet($findThis, $fullText, 50);

image

PS: and how you cant see - snippet not right show position of finding word, how I'm wrote early: https://github.com/teamtnt/tntsearch/issues/101

lgXenos commented 6 years ago

And $tnt->highlight() can't show correct text too in this case

$tnt->highlight($fullText, $this->searchPhrase, 'b', [
            'wholeWord' => false,
            'caseSensitive' => false
        ]);