mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-08-26 04:05:57 +00:00
Updated search indexer to split words better
Will now split up words based on more chars than just spaces. Not takes into account newlines, tabs, periods & commas. Fixed #531
This commit is contained in:
parent
87339e4cd0
commit
5fd04fa470
@ -382,11 +382,13 @@ class SearchService
|
|||||||
protected function generateTermArrayFromText($text, $scoreAdjustment = 1)
|
protected function generateTermArrayFromText($text, $scoreAdjustment = 1)
|
||||||
{
|
{
|
||||||
$tokenMap = []; // {TextToken => OccurrenceCount}
|
$tokenMap = []; // {TextToken => OccurrenceCount}
|
||||||
$splitText = explode(' ', $text);
|
$splitChars = " \n\t.,";
|
||||||
foreach ($splitText as $token) {
|
$token = strtok($text, $splitChars);
|
||||||
if ($token === '') continue;
|
|
||||||
|
while ($token !== false) {
|
||||||
if (!isset($tokenMap[$token])) $tokenMap[$token] = 0;
|
if (!isset($tokenMap[$token])) $tokenMap[$token] = 0;
|
||||||
$tokenMap[$token]++;
|
$tokenMap[$token]++;
|
||||||
|
$token = strtok($splitChars);
|
||||||
}
|
}
|
||||||
|
|
||||||
$terms = [];
|
$terms = [];
|
||||||
|
Loading…
Reference in New Issue
Block a user