From 61bbf8f071b76efd25eacbf5fb319d156528bc7f Mon Sep 17 00:00:00 2001 From: Mike Colagrosso Date: Thu, 6 Feb 2025 14:52:13 -0700 Subject: [PATCH] Add `idxSearchCombined` to match multiple fields The data in these fields are separate: * `IndexableText` * `Title` * `IndexableAuthors` * `IndexableCollections` There are also on indices on each of these fields so that they can have separate weight in the relevance scoring. --- config/sql/se/Ebooks.sql | 3 ++- lib/Ebook.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/config/sql/se/Ebooks.sql b/config/sql/se/Ebooks.sql index 795abf7d..b6f7c376 100644 --- a/config/sql/se/Ebooks.sql +++ b/config/sql/se/Ebooks.sql @@ -33,5 +33,6 @@ CREATE TABLE IF NOT EXISTS `Ebooks` ( FULLTEXT `idxSearch` (`IndexableText`), FULLTEXT `idxSearchTitle` (`Title`), FULLTEXT `idxSearchAuthors` (`IndexableAuthors`), - FULLTEXT `idxSearchCollections` (`IndexableCollections`) + FULLTEXT `idxSearchCollections` (`IndexableCollections`), + FULLTEXT `idxSearchCombined` (`IndexableText`, `Title`, `IndexableAuthors`, `IndexableCollections`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/lib/Ebook.php b/lib/Ebook.php index c18ce5e0..a22627c2 100644 --- a/lib/Ebook.php +++ b/lib/Ebook.php @@ -2481,7 +2481,7 @@ final class Ebook{ match(e.IndexableText) against (?) ) as RelevanceScore '; - $whereCondition .= ' and match(e.IndexableText) against(?) '; + $whereCondition .= ' and match(e.IndexableText, e.Title, e.IndexableAuthors, e.IndexableCollections) against(?) '; $params[] = $query; if($sort == null || $sort == Enums\EbookSortType::Relevance || $sort == Enums\EbookSortType::Newest){