From 4621ae2001637eb0004061f32ae81ee06510da73 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 26 Sep 2020 18:32:21 -0400 Subject: [PATCH 1/2] [Database v0008] Replace profile_url with username in profile full-text index - Prevents search matches on node domain name --- src/sql/migrations/down/0007.sql | 4 ++++ src/sql/migrations/up/0008.sql | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 src/sql/migrations/down/0007.sql create mode 100644 src/sql/migrations/up/0008.sql diff --git a/src/sql/migrations/down/0007.sql b/src/sql/migrations/down/0007.sql new file mode 100644 index 0000000..54afcf3 --- /dev/null +++ b/src/sql/migrations/down/0007.sql @@ -0,0 +1,4 @@ +BEGIN; +ALTER TABLE `profile` DROP KEY `profile-ft`; +ALTER TABLE `profile` ADD FULLTEXT KEY `profile-ft` (`name`, `pdesc`, `profile_url`, `locality`, `region`, `country`); +COMMIT; \ No newline at end of file diff --git a/src/sql/migrations/up/0008.sql b/src/sql/migrations/up/0008.sql new file mode 100644 index 0000000..74bf350 --- /dev/null +++ b/src/sql/migrations/up/0008.sql @@ -0,0 +1,4 @@ +BEGIN; +ALTER TABLE `profile` DROP KEY `profile-ft`; +ALTER TABLE `profile` ADD FULLTEXT KEY `profile-ft` (`name`, `pdesc`, `username`, `locality`, `region`, `country`); +COMMIT; -- 2.40.1 From d6bf75ae048e15d4cebbfa3c2829091068af2e79 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 26 Sep 2020 18:32:43 -0400 Subject: [PATCH 2/2] Update profile search request to match updated fulltext index definition --- src/classes/Controllers/Web/Search.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/classes/Controllers/Web/Search.php b/src/classes/Controllers/Web/Search.php index 39ae0ac..db8e332 100644 --- a/src/classes/Controllers/Web/Search.php +++ b/src/classes/Controllers/Web/Search.php @@ -69,7 +69,7 @@ class Search extends BaseController } } else { - $sql_where = "MATCH (p.`name`, p.`pdesc`, p.`profile_url`, p.`locality`, p.`region`, p.`country`, p.`tags` ) + $sql_where = "MATCH (p.`name`, p.`pdesc`, p.`username`, p.`locality`, p.`region`, p.`country`, p.`tags` ) AGAINST (:query IN BOOLEAN MODE)"; } -- 2.40.1