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:
Dan Brown 2017-09-30 14:14:23 +01:00
parent 87339e4cd0
commit 5fd04fa470
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9

View File

@ -382,11 +382,13 @@ class SearchService
protected function generateTermArrayFromText($text, $scoreAdjustment = 1)
{
$tokenMap = []; // {TextToken => OccurrenceCount}
$splitText = explode(' ', $text);
foreach ($splitText as $token) {
if ($token === '') continue;
$splitChars = " \n\t.,";
$token = strtok($text, $splitChars);
while ($token !== false) {
if (!isset($tokenMap[$token])) $tokenMap[$token] = 0;
$tokenMap[$token]++;
$token = strtok($splitChars);
}
$terms = [];