Add a Relevance sort order and improve search

Here's what's in `IndexableText` right now:

1. Title
2. Collections
3. Authors
4. Tags
5. LocSubjects
6. TocEntries

Here is the proposed new ranking:

```
10 * Title +
8 * Authors +
3 * Collections +
IndexableText
```

New indices for existing DBs:

```
ALTER TABLE `Ebooks` ADD COLUMN `IndexableAuthors` text NOT NULL;
ALTER TABLE `Ebooks` ADD COLUMN `IndexableCollections` text NULL;
ALTER TABLE `Ebooks` ADD FULLTEXT `indexSearchTitle` (`Title`);
ALTER TABLE `Ebooks` ADD FULLTEXT `idxSearchAuthors` (`IndexableAuthors`);
ALTER TABLE `Ebooks` ADD FULLTEXT `idxSearchCollections` (`IndexableCollections`);
```
This commit is contained in:
Mike Colagrosso 2025-01-24 20:42:18 -07:00 committed by Alex Cabal
parent b2df8a7018
commit 1a71913794
8 changed files with 120 additions and 15 deletions

View file

@ -31,6 +31,13 @@ class Formatter{
}
}
/**
* Remove diacritics and non-alphanumeric characters.
*/
public static function RemoveDiacriticsAndNonalphanumerics(string $text): string{
return trim(preg_replace('|[^a-zA-Z0-9 ]|ius', ' ', Formatter::RemoveDiacritics($text)));
}
/**
* Escape a string so that it's appropriate to use in a URL slug.
*