diff --git a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2018-04-14.sql b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2018-04-14.sql new file mode 100644 index 0000000000000..edb694db1e2fc --- /dev/null +++ b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2018-04-14.sql @@ -0,0 +1,45 @@ +CREATE TABLE `#__finder_links_terms` ( + `link_id` INT(10) UNSIGNED NOT NULL, + `term_id` INT(10) UNSIGNED NOT NULL, + `weight` FLOAT UNSIGNED NOT NULL, + PRIMARY KEY (`link_id`, `term_id`), + INDEX `idx_term_weight` (`term_id`, `weight`), + INDEX `idx_link_term_weight` (`link_id`, `term_id`, `weight`) +) +COLLATE='utf8mb4_general_ci' +ENGINE=InnoDB +; +DROP TABLE #__finder_links_terms0; +DROP TABLE #__finder_links_terms1; +DROP TABLE #__finder_links_terms2; +DROP TABLE #__finder_links_terms3; +DROP TABLE #__finder_links_terms4; +DROP TABLE #__finder_links_terms5; +DROP TABLE #__finder_links_terms6; +DROP TABLE #__finder_links_terms7; +DROP TABLE #__finder_links_terms8; +DROP TABLE #__finder_links_terms9; +DROP TABLE #__finder_links_termsa; +DROP TABLE #__finder_links_termsb; +DROP TABLE #__finder_links_termsc; +DROP TABLE #__finder_links_termsd; +DROP TABLE #__finder_links_termse; +DROP TABLE #__finder_links_termsf; + +ALTER TABLE `#__finder_terms` + CHANGE COLUMN `language` `language` CHAR(7) NOT NULL DEFAULT '' AFTER `links`; + +ALTER TABLE `#__finder_terms_common` + CHANGE COLUMN `language` `language` CHAR(7) NOT NULL DEFAULT '' AFTER `term`; + +ALTER TABLE `#__finder_tokens` + CHANGE COLUMN `language` `language` CHAR(7) NOT NULL DEFAULT '' AFTER `context`; + +ALTER TABLE `#__finder_tokens_aggregate` + DROP COLUMN `map_suffix`; + +ALTER TABLE `#__finder_tokens_aggregate` + CHANGE COLUMN `language` `language` CHAR(7) NOT NULL DEFAULT '' AFTER `total_weight`; + +ALTER TABLE `#__finder_links` + CHANGE COLUMN `language` `language` CHAR(7) NOT NULL DEFAULT '' AFTER `access`; \ No newline at end of file diff --git a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2018-04-14.sql b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2018-04-14.sql new file mode 100644 index 0000000000000..2c009f23c5a1b --- /dev/null +++ b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2018-04-14.sql @@ -0,0 +1,48 @@ +CREATE TABLE "#__finder_links_terms" ( + "link_id" bigint NOT NULL, + "term_id" bigint NOT NULL, + "weight" REAL NOT NULL, + PRIMARY KEY ("link_id", "term_id") +); +CREATE INDEX "idx_term_weight" ("term_id", "weight"); +CREATE INDEX "idx_link_term_weight" ("link_id", "term_id", "weight"); + +DROP TABLE "#__finder_links_terms0" CASCADE; +DROP TABLE "#__finder_links_terms1" CASCADE; +DROP TABLE "#__finder_links_terms2" CASCADE; +DROP TABLE "#__finder_links_terms3" CASCADE; +DROP TABLE "#__finder_links_terms4" CASCADE; +DROP TABLE "#__finder_links_terms5" CASCADE; +DROP TABLE "#__finder_links_terms6" CASCADE; +DROP TABLE "#__finder_links_terms7" CASCADE; +DROP TABLE "#__finder_links_terms8" CASCADE; +DROP TABLE "#__finder_links_terms9" CASCADE; +DROP TABLE "#__finder_links_termsa" CASCADE; +DROP TABLE "#__finder_links_termsb" CASCADE; +DROP TABLE "#__finder_links_termsc" CASCADE; +DROP TABLE "#__finder_links_termsd" CASCADE; +DROP TABLE "#__finder_links_termse" CASCADE; +DROP TABLE "#__finder_links_termsf" CASCADE; + +ALTER TABLE "#__finder_terms" + ALTER COLUMN "language" TYPE CHAR(7), + ALTER COLUMN "language" SET DEFAULT ''; + +ALTER TABLE "#__finder_common" + ALTER COLUMN "language" TYPE CHAR(7), + ALTER COLUMN "language" SET DEFAULT ''; + +ALTER TABLE "#__finder_tokens" + ALTER COLUMN "language" TYPE CHAR(7), + ALTER COLUMN "language" SET DEFAULT ''; + +ALTER TABLE "#__finder_tokens_aggregate" + ALTER COLUMN "language" TYPE CHAR(7), + ALTER COLUMN "language" SET DEFAULT ''; + +ALTER TABLE "#__finder_tokens_aggregate" + DROP COLUMN "map_suffix"; + +ALTER TABLE "#__finder_links" + ALTER COLUMN "language" TYPE CHAR(7), + ALTER COLUMN "language" SET DEFAULT ''; diff --git a/administrator/components/com_finder/Model/IndexModel.php b/administrator/components/com_finder/Model/IndexModel.php index 01d53c7b43903..b354ef7a89c1e 100644 --- a/administrator/components/com_finder/Model/IndexModel.php +++ b/administrator/components/com_finder/Model/IndexModel.php @@ -342,13 +342,7 @@ public function purge() $db->truncateTable('#__finder_links'); // Truncate the links terms tables. - for ($i = 0; $i <= 15; $i++) - { - // Get the mapping table suffix. - $suffix = dechex($i); - - $db->truncateTable('#__finder_links_terms' . $suffix); - } + $db->truncateTable('#__finder_links_terms'); // Truncate the terms table. $db->truncateTable('#__finder_terms'); diff --git a/administrator/components/com_finder/helpers/indexer/driver/mysql.php b/administrator/components/com_finder/helpers/indexer/driver/mysql.php index c91c1295e24a9..1cee30bb4d4e2 100644 --- a/administrator/components/com_finder/helpers/indexer/driver/mysql.php +++ b/administrator/components/com_finder/helpers/indexer/driver/mysql.php @@ -78,15 +78,12 @@ public function index($item, $format = 'html') */ if (!$isNew) { - for ($i = 0; $i <= 15; $i++) - { - // Flush the maps for the link. - $query->clear() - ->delete($db->quoteName('#__finder_links_terms' . dechex($i))) - ->where($db->quoteName('link_id') . ' = ' . (int) $linkId); - $db->setQuery($query); - $db->execute(); - } + // Flush the maps for the link. + $query->clear() + ->delete($db->quoteName('#__finder_links_terms')) + ->where($db->quoteName('link_id') . ' = ' . (int) $linkId); + $db->setQuery($query); + $db->execute(); // Remove the taxonomy maps. FinderIndexerTaxonomy::removeMaps($linkId); @@ -288,8 +285,7 @@ public function index($item, $format = 'html') */ $query = 'INSERT INTO ' . $db->quoteName('#__finder_tokens_aggregate') . ' (' . $db->quoteName('term_id') . - ', ' . $db->quoteName('map_suffix') . - ', ' . $db->quoteName('term') . + ', ' . $db->quoteName('term') . ', ' . $db->quoteName('stem') . ', ' . $db->quoteName('common') . ', ' . $db->quoteName('phrase') . @@ -299,7 +295,7 @@ public function index($item, $format = 'html') ', ' . $db->quoteName('total_weight') . ', ' . $db->quoteName('language') . ')' . ' SELECT' . - ' COALESCE(t.term_id, 0), \'\', t1.term, t1.stem, t1.common, t1.phrase, t1.weight, t1.context,' . + ' COALESCE(t.term_id, 0), t1.term, t1.stem, t1.common, t1.phrase, t1.weight, t1.context,' . ' ROUND( t1.weight * COUNT( t2.term ) * %F, 8 ) AS context_weight, 0, t1.language' . ' FROM (' . ' SELECT DISTINCT t1.term, t1.stem, t1.common, t1.phrase, t1.weight, t1.context, t1.language' . @@ -377,50 +373,25 @@ public function index($item, $format = 'html') // Mark afterTerms in the profiler. static::$profiler ? static::$profiler->mark('afterTerms') : null; - /* - * Before we can insert all of the mapping rows, we have to figure out - * which mapping table the rows need to be inserted into. The mapping - * table for each term is based on the first character of the md5 of - * the first character of the term. In php, it would be expressed as - * substr(md5(substr($token, 0, 1)), 0, 1) - */ - $query->clear() - ->update($db->quoteName('#__finder_tokens_aggregate')) - ->set($db->quoteName('map_suffix') . ' = SUBSTR(MD5(SUBSTR(' . $db->quoteName('term') . ', 1, 1)), 1, 1)'); - $db->setQuery($query); - $db->execute(); - /* * At this point, the aggregate table contains a record for each * term in each context. So, we're going to pull down all of that * data while grouping the records by term and add all of the * sub-totals together to arrive at the final total for each token for - * this link. Then, we insert all of that data into the appropriate - * mapping table. + * this link. Then, we insert all of that data into the mapping table. */ - for ($i = 0; $i <= 15; $i++) - { - // Get the mapping table suffix. - $suffix = dechex($i); - - /* - * We have to run this query 16 times, one for each link => term - * mapping table. - */ - $db->setQuery( - 'INSERT INTO ' . $db->quoteName('#__finder_links_terms' . $suffix) . - ' (' . $db->quoteName('link_id') . - ', ' . $db->quoteName('term_id') . - ', ' . $db->quoteName('weight') . ')' . - ' SELECT ' . (int) $linkId . ', ' . $db->quoteName('term_id') . ',' . - ' ROUND(SUM(' . $db->quoteName('context_weight') . '), 8)' . - ' FROM ' . $db->quoteName('#__finder_tokens_aggregate') . - ' WHERE ' . $db->quoteName('map_suffix') . ' = ' . $db->quote($suffix) . - ' GROUP BY ' . $db->quoteName('term') . ', ' . $db->quoteName('term_id') . - ' ORDER BY ' . $db->quoteName('term') . ' DESC' - ); - $db->execute(); - } + $db->setQuery( + 'INSERT INTO ' . $db->quoteName('#__finder_links_terms') . + ' (' . $db->quoteName('link_id') . + ', ' . $db->quoteName('term_id') . + ', ' . $db->quoteName('weight') . ')' . + ' SELECT ' . (int) $linkId . ', ' . $db->quoteName('term_id') . ',' . + ' ROUND(SUM(' . $db->quoteName('context_weight') . '), 8)' . + ' FROM ' . $db->quoteName('#__finder_tokens_aggregate') . + ' GROUP BY ' . $db->quoteName('term') . ', ' . $db->quoteName('term_id') . + ' ORDER BY ' . $db->quoteName('term') . ' DESC' + ); + $db->execute(); // Mark afterMapping in the profiler. static::$profiler ? static::$profiler->mark('afterMapping') : null; @@ -476,12 +447,9 @@ public function optimize() $db->setQuery('OPTIMIZE TABLE ' . $db->quoteName('#__finder_links')); $db->execute(); - for ($i = 0; $i <= 15; $i++) - { - // Optimize the terms mapping table. - $db->setQuery('OPTIMIZE TABLE ' . $db->quoteName('#__finder_links_terms' . dechex($i))); - $db->execute(); - } + // Optimize the terms mapping table. + $db->setQuery('OPTIMIZE TABLE ' . $db->quoteName('#__finder_links_terms')); + $db->execute(); // Optimize the filters table. $db->setQuery('OPTIMIZE TABLE ' . $db->quoteName('#__finder_filters')); diff --git a/administrator/components/com_finder/helpers/indexer/driver/postgresql.php b/administrator/components/com_finder/helpers/indexer/driver/postgresql.php index 10a695fd83b69..41b6abd5b3014 100644 --- a/administrator/components/com_finder/helpers/indexer/driver/postgresql.php +++ b/administrator/components/com_finder/helpers/indexer/driver/postgresql.php @@ -70,15 +70,12 @@ public function index($item, $format = 'html') */ if (!$isNew) { - for ($i = 0; $i <= 15; $i++) - { - // Flush the maps for the link. - $query->clear() - ->delete($db->quoteName('#__finder_links_terms' . dechex($i))) - ->where($db->quoteName('link_id') . ' = ' . (int) $linkId); - $db->setQuery($query); - $db->execute(); - } + // Flush the maps for the link. + $query->clear() + ->delete($db->quoteName('#__finder_links_terms')) + ->where($db->quoteName('link_id') . ' = ' . (int) $linkId); + $db->setQuery($query); + $db->execute(); // Remove the taxonomy maps. FinderIndexerTaxonomy::removeMaps($linkId); @@ -378,19 +375,6 @@ public function index($item, $format = 'html') // Mark afterTerms in the profiler. static::$profiler ? static::$profiler->mark('afterTerms') : null; - /* - * Before we can insert all of the mapping rows, we have to figure out - * which mapping table the rows need to be inserted into. The mapping - * table for each term is based on the first character of the md5 of - * the first character of the term. In php, it would be expressed as - * substr(md5(substr($token, 0, 1)), 0, 1) - */ - $query->clear() - ->update($db->quoteName('#__finder_tokens_aggregate')) - ->set($db->quoteName('map_suffix') . ' = SUBSTR(MD5(SUBSTR(' . $db->quoteName('term') . ', 1, 1)), 1, 1)'); - $db->setQuery($query); - $db->execute(); - /* * At this point, the aggregate table contains a record for each * term in each context. So, we're going to pull down all of that @@ -399,29 +383,18 @@ public function index($item, $format = 'html') * this link. Then, we insert all of that data into the appropriate * mapping table. */ - for ($i = 0; $i <= 15; $i++) - { - // Get the mapping table suffix. - $suffix = dechex($i); - - /* - * We have to run this query 16 times, one for each link => term - * mapping table. - */ - $db->setQuery( - 'INSERT INTO ' . $db->quoteName('#__finder_links_terms' . $suffix) . - ' (' . $db->quoteName('link_id') . - ', ' . $db->quoteName('term_id') . - ', ' . $db->quoteName('weight') . ')' . - ' SELECT ' . (int) $linkId . ', ' . $db->quoteName('term_id') . ',' . - ' ROUND(SUM(' . $db->quoteName('context_weight') . '), 8)' . - ' FROM ' . $db->quoteName('#__finder_tokens_aggregate') . - ' WHERE ' . $db->quoteName('map_suffix') . ' = ' . $db->quote($suffix) . - ' GROUP BY ' . $db->quoteName('term') . ', ' . $db->quoteName('term_id') . - ' ORDER BY ' . $db->quoteName('term') . ' DESC' - ); - $db->execute(); - } + $db->setQuery( + 'INSERT INTO ' . $db->quoteName('#__finder_links_terms') . + ' (' . $db->quoteName('link_id') . + ', ' . $db->quoteName('term_id') . + ', ' . $db->quoteName('weight') . ')' . + ' SELECT ' . (int) $linkId . ', ' . $db->quoteName('term_id') . ',' . + ' ROUND(SUM(' . $db->quoteName('context_weight') . '), 8)' . + ' FROM ' . $db->quoteName('#__finder_tokens_aggregate') . + ' GROUP BY ' . $db->quoteName('term') . ', ' . $db->quoteName('term_id') . + ' ORDER BY ' . $db->quoteName('term') . ' DESC' + ); + $db->execute(); // Mark afterMapping in the profiler. static::$profiler ? static::$profiler->mark('afterMapping') : null; @@ -479,14 +452,11 @@ public function optimize() $db->setQuery('REINDEX TABLE ' . $db->quoteName('#__finder_links')); $db->execute(); - for ($i = 0; $i <= 15; $i++) - { - // Optimize the terms mapping table. - $db->setQuery('VACUUM ' . $db->quoteName('#__finder_links_terms' . dechex($i))); - $db->execute(); - $db->setQuery('REINDEX TABLE ' . $db->quoteName('#__finder_links_terms' . dechex($i))); - $db->execute(); - } + // Optimize the terms mapping table. + $db->setQuery('VACUUM ' . $db->quoteName('#__finder_links_terms')); + $db->execute(); + $db->setQuery('REINDEX TABLE ' . $db->quoteName('#__finder_links_terms')); + $db->execute(); // Optimize the filters table. $db->setQuery('REINDEX TABLE ' . $db->quoteName('#__finder_filters')); diff --git a/administrator/components/com_finder/helpers/indexer/indexer.php b/administrator/components/com_finder/helpers/indexer/indexer.php index f72fe76e263fa..c4c1713300dd9 100644 --- a/administrator/components/com_finder/helpers/indexer/indexer.php +++ b/administrator/components/com_finder/helpers/indexer/indexer.php @@ -295,23 +295,19 @@ public function remove($linkId) $db = $this->db; $query = $db->getQuery(true); - // Update the link counts and remove the mapping records. - for ($i = 0; $i <= 15; $i++) - { - // Update the link counts for the terms. - $query->clear() - ->update($db->quoteName('#__finder_terms', 't')) - ->join('INNER', $db->quoteName('#__finder_links_terms' . dechex($i), 'm') . ' ON m.term_id = t.term_id') - ->set('t.links = t.links - 1') - ->where($db->quoteName('m.link_id') . ' = ' . (int) $linkId); - $db->setQuery($query)->execute(); + // Update the link counts for the terms. + $query->clear() + ->update($db->quoteName('#__finder_terms', 't')) + ->join('INNER', $db->quoteName('#__finder_links_terms', 'm') . ' ON m.term_id = t.term_id') + ->set('t.links = t.links - 1') + ->where($db->quoteName('m.link_id') . ' = ' . (int) $linkId); + $db->setQuery($query)->execute(); - // Remove all records from the mapping tables. - $query->clear() - ->delete($db->quoteName('#__finder_links_terms' . dechex($i))) - ->where($db->quoteName('link_id') . ' = ' . (int) $linkId); - $db->setQuery($query)->execute(); - } + // Remove all records from the mapping tables. + $query->clear() + ->delete($db->quoteName('#__finder_links_terms')) + ->where($db->quoteName('link_id') . ' = ' . (int) $linkId); + $db->setQuery($query)->execute(); // Delete all orphaned terms. $query->clear() diff --git a/administrator/components/com_finder/sql/install.mysql.sql b/administrator/components/com_finder/sql/install.mysql.sql index 4207fa2111075..6df173ecc27d6 100644 --- a/administrator/components/com_finder/sql/install.mysql.sql +++ b/administrator/components/com_finder/sql/install.mysql.sql @@ -35,7 +35,7 @@ CREATE TABLE IF NOT EXISTS `#__finder_links` ( `published` tinyint(1) NOT NULL DEFAULT 1, `state` int(5) DEFAULT 1, `access` int(5) DEFAULT 0, - `language` varchar(8) NOT NULL, + `language` char(7) NOT NULL, `publish_start_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `publish_end_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `start_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', @@ -54,205 +54,10 @@ CREATE TABLE IF NOT EXISTS `#__finder_links` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; -- --- Table structure for table `#__finder_links_terms0` +-- Table structure for table `#__finder_links_terms` -- -CREATE TABLE IF NOT EXISTS `#__finder_links_terms0` ( - `link_id` int(10) unsigned NOT NULL, - `term_id` int(10) unsigned NOT NULL, - `weight` float unsigned NOT NULL, - PRIMARY KEY (`link_id`,`term_id`), - KEY `idx_term_weight` (`term_id`,`weight`), - KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; - --- --- Table structure for table `#__finder_links_terms1` --- - -CREATE TABLE IF NOT EXISTS `#__finder_links_terms1` ( - `link_id` int(10) unsigned NOT NULL, - `term_id` int(10) unsigned NOT NULL, - `weight` float unsigned NOT NULL, - PRIMARY KEY (`link_id`,`term_id`), - KEY `idx_term_weight` (`term_id`,`weight`), - KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; - --- --- Table structure for table `#__finder_links_terms2` --- - -CREATE TABLE IF NOT EXISTS `#__finder_links_terms2` ( - `link_id` int(10) unsigned NOT NULL, - `term_id` int(10) unsigned NOT NULL, - `weight` float unsigned NOT NULL, - PRIMARY KEY (`link_id`,`term_id`), - KEY `idx_term_weight` (`term_id`,`weight`), - KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; - --- --- Table structure for table `#__finder_links_terms3` --- - -CREATE TABLE IF NOT EXISTS `#__finder_links_terms3` ( - `link_id` int(10) unsigned NOT NULL, - `term_id` int(10) unsigned NOT NULL, - `weight` float unsigned NOT NULL, - PRIMARY KEY (`link_id`,`term_id`), - KEY `idx_term_weight` (`term_id`,`weight`), - KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; - --- --- Table structure for table `#__finder_links_terms4` --- - -CREATE TABLE IF NOT EXISTS `#__finder_links_terms4` ( - `link_id` int(10) unsigned NOT NULL, - `term_id` int(10) unsigned NOT NULL, - `weight` float unsigned NOT NULL, - PRIMARY KEY (`link_id`,`term_id`), - KEY `idx_term_weight` (`term_id`,`weight`), - KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; - --- --- Table structure for table `#__finder_links_terms5` --- - -CREATE TABLE IF NOT EXISTS `#__finder_links_terms5` ( - `link_id` int(10) unsigned NOT NULL, - `term_id` int(10) unsigned NOT NULL, - `weight` float unsigned NOT NULL, - PRIMARY KEY (`link_id`,`term_id`), - KEY `idx_term_weight` (`term_id`,`weight`), - KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; - --- --- Table structure for table `#__finder_links_terms6` --- - -CREATE TABLE IF NOT EXISTS `#__finder_links_terms6` ( - `link_id` int(10) unsigned NOT NULL, - `term_id` int(10) unsigned NOT NULL, - `weight` float unsigned NOT NULL, - PRIMARY KEY (`link_id`,`term_id`), - KEY `idx_term_weight` (`term_id`,`weight`), - KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; - --- --- Table structure for table `#__finder_links_terms7` --- - -CREATE TABLE IF NOT EXISTS `#__finder_links_terms7` ( - `link_id` int(10) unsigned NOT NULL, - `term_id` int(10) unsigned NOT NULL, - `weight` float unsigned NOT NULL, - PRIMARY KEY (`link_id`,`term_id`), - KEY `idx_term_weight` (`term_id`,`weight`), - KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; - --- --- Table structure for table `#__finder_links_terms8` --- - -CREATE TABLE IF NOT EXISTS `#__finder_links_terms8` ( - `link_id` int(10) unsigned NOT NULL, - `term_id` int(10) unsigned NOT NULL, - `weight` float unsigned NOT NULL, - PRIMARY KEY (`link_id`,`term_id`), - KEY `idx_term_weight` (`term_id`,`weight`), - KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; - --- --- Table structure for table `#__finder_links_terms9` --- - -CREATE TABLE IF NOT EXISTS `#__finder_links_terms9` ( - `link_id` int(10) unsigned NOT NULL, - `term_id` int(10) unsigned NOT NULL, - `weight` float unsigned NOT NULL, - PRIMARY KEY (`link_id`,`term_id`), - KEY `idx_term_weight` (`term_id`,`weight`), - KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; - --- --- Table structure for table `#__finder_links_termsa` --- - -CREATE TABLE IF NOT EXISTS `#__finder_links_termsa` ( - `link_id` int(10) unsigned NOT NULL, - `term_id` int(10) unsigned NOT NULL, - `weight` float unsigned NOT NULL, - PRIMARY KEY (`link_id`,`term_id`), - KEY `idx_term_weight` (`term_id`,`weight`), - KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; - --- --- Table structure for table `#__finder_links_termsb` --- - -CREATE TABLE IF NOT EXISTS `#__finder_links_termsb` ( - `link_id` int(10) unsigned NOT NULL, - `term_id` int(10) unsigned NOT NULL, - `weight` float unsigned NOT NULL, - PRIMARY KEY (`link_id`,`term_id`), - KEY `idx_term_weight` (`term_id`,`weight`), - KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; - --- --- Table structure for table `#__finder_links_termsc` --- - -CREATE TABLE IF NOT EXISTS `#__finder_links_termsc` ( - `link_id` int(10) unsigned NOT NULL, - `term_id` int(10) unsigned NOT NULL, - `weight` float unsigned NOT NULL, - PRIMARY KEY (`link_id`,`term_id`), - KEY `idx_term_weight` (`term_id`,`weight`), - KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; - --- --- Table structure for table `#__finder_links_termsd` --- - -CREATE TABLE IF NOT EXISTS `#__finder_links_termsd` ( - `link_id` int(10) unsigned NOT NULL, - `term_id` int(10) unsigned NOT NULL, - `weight` float unsigned NOT NULL, - PRIMARY KEY (`link_id`,`term_id`), - KEY `idx_term_weight` (`term_id`,`weight`), - KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; - --- --- Table structure for table `#__finder_links_termse` --- - -CREATE TABLE IF NOT EXISTS `#__finder_links_termse` ( - `link_id` int(10) unsigned NOT NULL, - `term_id` int(10) unsigned NOT NULL, - `weight` float unsigned NOT NULL, - PRIMARY KEY (`link_id`,`term_id`), - KEY `idx_term_weight` (`term_id`,`weight`), - KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; - --- --- Table structure for table `#__finder_links_termsf` --- - -CREATE TABLE IF NOT EXISTS `#__finder_links_termsf` ( +CREATE TABLE IF NOT EXISTS `#__finder_links_terms` ( `link_id` int(10) unsigned NOT NULL, `term_id` int(10) unsigned NOT NULL, `weight` float unsigned NOT NULL, @@ -312,7 +117,7 @@ CREATE TABLE IF NOT EXISTS `#__finder_terms` ( `weight` float unsigned NOT NULL DEFAULT 0, `soundex` varchar(75) NOT NULL, `links` int(10) NOT NULL DEFAULT 0, - `language` char(3) NOT NULL DEFAULT '', + `language` char(7) NOT NULL DEFAULT '', PRIMARY KEY (`term_id`), UNIQUE KEY `idx_term` (`term`), KEY `idx_term_phrase` (`term`,`phrase`), @@ -326,7 +131,7 @@ CREATE TABLE IF NOT EXISTS `#__finder_terms` ( CREATE TABLE IF NOT EXISTS `#__finder_terms_common` ( `term` varchar(75) NOT NULL, - `language` varchar(3) NOT NULL, + `language` char(7) NOT NULL, KEY `idx_word_lang` (`term`,`language`), KEY `idx_lang` (`language`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; @@ -458,7 +263,7 @@ CREATE TABLE IF NOT EXISTS `#__finder_tokens` ( `phrase` tinyint(1) unsigned NOT NULL DEFAULT 0, `weight` float unsigned NOT NULL DEFAULT 1, `context` tinyint(1) unsigned NOT NULL DEFAULT 2, - `language` char(3) NOT NULL DEFAULT '', + `language` char(7) NOT NULL DEFAULT '', KEY `idx_word` (`term`), KEY `idx_context` (`context`) ) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; @@ -469,7 +274,6 @@ CREATE TABLE IF NOT EXISTS `#__finder_tokens` ( CREATE TABLE IF NOT EXISTS `#__finder_tokens_aggregate` ( `term_id` int(10) unsigned NOT NULL, - `map_suffix` char(1) NOT NULL, `term` varchar(75) NOT NULL, `stem` varchar(75) NOT NULL, `common` tinyint(1) unsigned NOT NULL DEFAULT 0, @@ -478,7 +282,7 @@ CREATE TABLE IF NOT EXISTS `#__finder_tokens_aggregate` ( `context` tinyint(1) unsigned NOT NULL DEFAULT 2, `context_weight` float unsigned NOT NULL, `total_weight` float unsigned NOT NULL, - `language` char(3) NOT NULL DEFAULT '', + `language` char(7) NOT NULL DEFAULT '', KEY `token` (`term`), KEY `keyword_id` (`term_id`) ) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; diff --git a/administrator/components/com_finder/sql/install.postgresql.sql b/administrator/components/com_finder/sql/install.postgresql.sql index 6c125dcecc439..69db285c6b4b0 100644 --- a/administrator/components/com_finder/sql/install.postgresql.sql +++ b/administrator/components/com_finder/sql/install.postgresql.sql @@ -52,9 +52,9 @@ CREATE INDEX "#__finder_links_idx_published_list" on "#__finder_links" ("publish CREATE INDEX "#__finder_links_idx_published_sale" on "#__finder_links" ("published", "state", "access", "publish_start_date", "publish_end_date", "sale_price"); -- --- Table: #__finder_links_terms0 +-- Table: #__finder_links_terms -- -CREATE TABLE IF NOT EXISTS "#__finder_links_terms0" ( +CREATE TABLE IF NOT EXISTS "#__finder_links_terms" ( "link_id" integer NOT NULL, "term_id" integer NOT NULL, "weight" numeric(8,2) NOT NULL, @@ -63,186 +63,6 @@ CREATE TABLE IF NOT EXISTS "#__finder_links_terms0" ( CREATE INDEX "#__finder_links_terms0_idx_term_weight" on "#__finder_links_terms0" ("term_id", "weight"); CREATE INDEX "#__finder_links_terms0_idx_link_term_weight" on "#__finder_links_terms0" ("link_id", "term_id", "weight"); --- --- Table: #__finder_links_terms1 --- -CREATE TABLE IF NOT EXISTS "#__finder_links_terms1" ( - "link_id" integer NOT NULL, - "term_id" integer NOT NULL, - "weight" numeric(8,2) NOT NULL, - PRIMARY KEY ("link_id", "term_id") -); -CREATE INDEX "#__finder_links_terms1_idx_term_weight" on "#__finder_links_terms1" ("term_id", "weight"); -CREATE INDEX "#__finder_links_terms1_idx_link_term_weight" on "#__finder_links_terms1" ("link_id", "term_id", "weight"); - --- --- Table: #__finder_links_terms2 --- -CREATE TABLE IF NOT EXISTS "#__finder_links_terms2" ( - "link_id" integer NOT NULL, - "term_id" integer NOT NULL, - "weight" numeric(8,2) NOT NULL, - PRIMARY KEY ("link_id", "term_id") -); -CREATE INDEX "#__finder_links_terms2_idx_term_weight" on "#__finder_links_terms2" ("term_id", "weight"); -CREATE INDEX "#__finder_links_terms2_idx_link_term_weight" on "#__finder_links_terms2" ("link_id", "term_id", "weight"); - --- --- Table: #__finder_links_terms3 --- -CREATE TABLE IF NOT EXISTS "#__finder_links_terms3" ( - "link_id" integer NOT NULL, - "term_id" integer NOT NULL, - "weight" numeric(8,2) NOT NULL, - PRIMARY KEY ("link_id", "term_id") -); -CREATE INDEX "#__finder_links_terms3_idx_term_weight" on "#__finder_links_terms3" ("term_id", "weight"); -CREATE INDEX "#__finder_links_terms3_idx_link_term_weight" on "#__finder_links_terms3" ("link_id", "term_id", "weight"); - --- --- Table: #__finder_links_terms4 --- -CREATE TABLE IF NOT EXISTS "#__finder_links_terms4" ( - "link_id" integer NOT NULL, - "term_id" integer NOT NULL, - "weight" numeric(8,2) NOT NULL, - PRIMARY KEY ("link_id", "term_id") -); -CREATE INDEX "#__finder_links_terms4_idx_term_weight" on "#__finder_links_terms4" ("term_id", "weight"); -CREATE INDEX "#__finder_links_terms4_idx_link_term_weight" on "#__finder_links_terms4" ("link_id", "term_id", "weight"); - --- --- Table: #__finder_links_terms5 --- -CREATE TABLE IF NOT EXISTS "#__finder_links_terms5" ( - "link_id" integer NOT NULL, - "term_id" integer NOT NULL, - "weight" numeric(8,2) NOT NULL, - PRIMARY KEY ("link_id", "term_id") -); -CREATE INDEX "#__finder_links_terms5_idx_term_weight" on "#__finder_links_terms5" ("term_id", "weight"); -CREATE INDEX "#__finder_links_terms5_idx_link_term_weight" on "#__finder_links_terms5" ("link_id", "term_id", "weight"); - --- --- Table: #__finder_links_terms6 --- -CREATE TABLE IF NOT EXISTS "#__finder_links_terms6" ( - "link_id" integer NOT NULL, - "term_id" integer NOT NULL, - "weight" numeric(8,2) NOT NULL, - PRIMARY KEY ("link_id", "term_id") -); -CREATE INDEX "#__finder_links_terms6_idx_term_weight" on "#__finder_links_terms6" ("term_id", "weight"); -CREATE INDEX "#__finder_links_terms6_idx_link_term_weight" on "#__finder_links_terms6" ("link_id", "term_id", "weight"); - --- --- Table: #__finder_links_terms7 --- -CREATE TABLE IF NOT EXISTS "#__finder_links_terms7" ( - "link_id" integer NOT NULL, - "term_id" integer NOT NULL, - "weight" numeric(8,2) NOT NULL, - PRIMARY KEY ("link_id", "term_id") -); -CREATE INDEX "#__finder_links_terms7_idx_term_weight" on "#__finder_links_terms7" ("term_id", "weight"); -CREATE INDEX "#__finder_links_terms7_idx_link_term_weight" on "#__finder_links_terms7" ("link_id", "term_id", "weight"); - --- --- Table: #__finder_links_terms8 --- -CREATE TABLE IF NOT EXISTS "#__finder_links_terms8" ( - "link_id" integer NOT NULL, - "term_id" integer NOT NULL, - "weight" numeric(8,2) NOT NULL, - PRIMARY KEY ("link_id", "term_id") -); -CREATE INDEX "#__finder_links_terms8_idx_term_weight" on "#__finder_links_terms8" ("term_id", "weight"); -CREATE INDEX "#__finder_links_terms8_idx_link_term_weight" on "#__finder_links_terms8" ("link_id", "term_id", "weight"); - --- --- Table: #__finder_links_terms9 --- -CREATE TABLE IF NOT EXISTS "#__finder_links_terms9" ( - "link_id" integer NOT NULL, - "term_id" integer NOT NULL, - "weight" numeric(8,2) NOT NULL, - PRIMARY KEY ("link_id", "term_id") -); -CREATE INDEX "#__finder_links_terms9_idx_term_weight" on "#__finder_links_terms9" ("term_id", "weight"); -CREATE INDEX "#__finder_links_terms9_idx_link_term_weight" on "#__finder_links_terms9" ("link_id", "term_id", "weight"); - --- --- Table: #__finder_links_termsa --- -CREATE TABLE IF NOT EXISTS "#__finder_links_termsa" ( - "link_id" integer NOT NULL, - "term_id" integer NOT NULL, - "weight" numeric(8,2) NOT NULL, - PRIMARY KEY ("link_id", "term_id") -); -CREATE INDEX "#__finder_links_termsa_idx_term_weight" on "#__finder_links_termsa" ("term_id", "weight"); -CREATE INDEX "#__finder_links_termsa_idx_link_term_weight" on "#__finder_links_termsa" ("link_id", "term_id", "weight"); - --- --- Table: #__finder_links_termsb --- -CREATE TABLE IF NOT EXISTS "#__finder_links_termsb" ( - "link_id" integer NOT NULL, - "term_id" integer NOT NULL, - "weight" numeric(8,2) NOT NULL, - PRIMARY KEY ("link_id", "term_id") -); -CREATE INDEX "#__finder_links_termsb_idx_term_weight" on "#__finder_links_termsb" ("term_id", "weight"); -CREATE INDEX "#__finder_links_termsb_idx_link_term_weight" on "#__finder_links_termsb" ("link_id", "term_id", "weight"); - --- --- Table: #__finder_links_termsc --- -CREATE TABLE IF NOT EXISTS "#__finder_links_termsc" ( - "link_id" integer NOT NULL, - "term_id" integer NOT NULL, - "weight" numeric(8,2) NOT NULL, - PRIMARY KEY ("link_id", "term_id") -); -CREATE INDEX "#__finder_links_termsc_idx_term_weight" on "#__finder_links_termsc" ("term_id", "weight"); -CREATE INDEX "#__finder_links_termsc_idx_link_term_weight" on "#__finder_links_termsc" ("link_id", "term_id", "weight"); - --- --- Table: #__finder_links_termsd --- -CREATE TABLE IF NOT EXISTS "#__finder_links_termsd" ( - "link_id" integer NOT NULL, - "term_id" integer NOT NULL, - "weight" numeric(8,2) NOT NULL, - PRIMARY KEY ("link_id", "term_id") -); -CREATE INDEX "#__finder_links_termsd_idx_term_weight" on "#__finder_links_termsd" ("term_id", "weight"); -CREATE INDEX "#__finder_links_termsd_idx_link_term_weight" on "#__finder_links_termsd" ("link_id", "term_id", "weight"); - --- --- Table: #__finder_links_termse --- -CREATE TABLE IF NOT EXISTS "#__finder_links_termse" ( - "link_id" integer NOT NULL, - "term_id" integer NOT NULL, - "weight" numeric(8,2) NOT NULL, - PRIMARY KEY ("link_id", "term_id") -); -CREATE INDEX "#__finder_links_termse_idx_term_weight" on "#__finder_links_termse" ("term_id", "weight"); -CREATE INDEX "#__finder_links_termse_idx_link_term_weight" on "#__finder_links_termse" ("link_id", "term_id", "weight"); - --- --- Table: #__finder_links_termsf --- -CREATE TABLE IF NOT EXISTS "#__finder_links_termsf" ( - "link_id" integer NOT NULL, - "term_id" integer NOT NULL, - "weight" numeric(8,2) NOT NULL, - PRIMARY KEY ("link_id", "term_id") -); -CREATE INDEX "#__finder_links_termsf_idx_term_weight" on "#__finder_links_termsf" ("term_id", "weight"); -CREATE INDEX "#__finder_links_termsf_idx_link_term_weight" on "#__finder_links_termsf" ("link_id", "term_id", "weight"); - -- -- Table: #__finder_taxonomy -- @@ -999,7 +819,6 @@ CREATE INDEX "#__finder_tokens_idx_context" on "#__finder_tokens" ("context"); -- CREATE TABLE IF NOT EXISTS "#__finder_tokens_aggregate" ( "term_id" integer NOT NULL, - "map_suffix" character(1) NOT NULL, "term" character varying(75) NOT NULL, "stem" character varying(75) NOT NULL, "common" smallint DEFAULT 0 NOT NULL, diff --git a/administrator/components/com_finder/sql/uninstall.mysql.sql b/administrator/components/com_finder/sql/uninstall.mysql.sql index 89579b982d43f..59d1b7a9b9491 100644 --- a/administrator/components/com_finder/sql/uninstall.mysql.sql +++ b/administrator/components/com_finder/sql/uninstall.mysql.sql @@ -1,21 +1,6 @@ DROP TABLE IF EXISTS `#__finder_filters`; DROP TABLE IF EXISTS `#__finder_links`; -DROP TABLE IF EXISTS `#__finder_links_terms0`; -DROP TABLE IF EXISTS `#__finder_links_terms1`; -DROP TABLE IF EXISTS `#__finder_links_terms2`; -DROP TABLE IF EXISTS `#__finder_links_terms3`; -DROP TABLE IF EXISTS `#__finder_links_terms4`; -DROP TABLE IF EXISTS `#__finder_links_terms5`; -DROP TABLE IF EXISTS `#__finder_links_terms6`; -DROP TABLE IF EXISTS `#__finder_links_terms7`; -DROP TABLE IF EXISTS `#__finder_links_terms8`; -DROP TABLE IF EXISTS `#__finder_links_terms9`; -DROP TABLE IF EXISTS `#__finder_links_termsa`; -DROP TABLE IF EXISTS `#__finder_links_termsb`; -DROP TABLE IF EXISTS `#__finder_links_termsc`; -DROP TABLE IF EXISTS `#__finder_links_termsd`; -DROP TABLE IF EXISTS `#__finder_links_termse`; -DROP TABLE IF EXISTS `#__finder_links_termsf`; +DROP TABLE IF EXISTS `#__finder_links_terms`; DROP TABLE IF EXISTS `#__finder_taxonomy`; DROP TABLE IF EXISTS `#__finder_taxonomy_map`; DROP TABLE IF EXISTS `#__finder_terms`; diff --git a/administrator/components/com_finder/sql/uninstall.postgresql.sql b/administrator/components/com_finder/sql/uninstall.postgresql.sql index 76d7981529149..6bc222650b261 100644 --- a/administrator/components/com_finder/sql/uninstall.postgresql.sql +++ b/administrator/components/com_finder/sql/uninstall.postgresql.sql @@ -1,21 +1,6 @@ DROP TABLE IF EXISTS "#__finder_filters"; DROP TABLE IF EXISTS "#__finder_links"; -DROP TABLE IF EXISTS "#__finder_links_terms0"; -DROP TABLE IF EXISTS "#__finder_links_terms1"; -DROP TABLE IF EXISTS "#__finder_links_terms2"; -DROP TABLE IF EXISTS "#__finder_links_terms3"; -DROP TABLE IF EXISTS "#__finder_links_terms4"; -DROP TABLE IF EXISTS "#__finder_links_terms5"; -DROP TABLE IF EXISTS "#__finder_links_terms6"; -DROP TABLE IF EXISTS "#__finder_links_terms7"; -DROP TABLE IF EXISTS "#__finder_links_terms8"; -DROP TABLE IF EXISTS "#__finder_links_terms9"; -DROP TABLE IF EXISTS "#__finder_links_termsa"; -DROP TABLE IF EXISTS "#__finder_links_termsb"; -DROP TABLE IF EXISTS "#__finder_links_termsc"; -DROP TABLE IF EXISTS "#__finder_links_termsd"; -DROP TABLE IF EXISTS "#__finder_links_termse"; -DROP TABLE IF EXISTS "#__finder_links_termsf"; +DROP TABLE IF EXISTS "#__finder_links_terms"; DROP TABLE IF EXISTS "#__finder_taxonomy"; DROP TABLE IF EXISTS "#__finder_taxonomy_map"; DROP TABLE IF EXISTS "#__finder_terms"; diff --git a/components/com_finder/Model/SearchModel.php b/components/com_finder/Model/SearchModel.php index 14429298a8957..c2423e89f3771 100644 --- a/components/com_finder/Model/SearchModel.php +++ b/components/com_finder/Model/SearchModel.php @@ -3,7 +3,7 @@ * @package Joomla.Site * @subpackage com_finder * - * @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved. + * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Finder\Site\Model; @@ -45,7 +45,7 @@ class SearchModel extends ListModel * @var \FinderIndexerQuery * @since 2.5 */ - protected $query; + protected $searchquery; /** * An array of all excluded terms ids. @@ -79,31 +79,9 @@ class SearchModel extends ListModel * @since 2.5 * @throws \Exception on database error. */ - public function getResults() + public function getItems() { - // Check if the search query is valid. - if (empty($this->query->search)) - { - return null; - } - - // Check if we should return results. - if (empty($this->includedTerms) && (empty($this->query->filters) || !$this->query->empty)) - { - return null; - } - - // Get the store id. - $store = $this->getStoreId('getResults'); - - // Use the cached data if possible. - if ($this->retrieve($store)) - { - return $this->retrieve($store); - } - - // Get the row data. - $items = $this->getResultsData(); + $items = parent::getItems(); // Check the data. if (empty($items)) @@ -111,81 +89,20 @@ public function getResults() return null; } - // Create the query to get the search results. - $db = $this->getDbo(); - $query = $db->getQuery(true) - ->select($db->quoteName('link_id') . ', ' . $db->quoteName('object')) - ->from($db->quoteName('#__finder_links')) - ->where($db->quoteName('link_id') . ' IN (' . implode(',', array_keys($items)) . ')'); - - // Load the results from the database. - $db->setQuery($query); - $rows = $db->loadObjectList('link_id'); - - // Set up our results container. - $results = $items; + $results = array(); // Convert the rows to result objects. - foreach ($rows as $rk => $row) + foreach ($items as $rk => $row) { // Build the result object. $result = unserialize($row->object); - $result->weight = $results[$rk]; - $result->link_id = $rk; // Add the result back to the stack. - $results[$rk] = $result; + $results[] = $result; } - // Switch to a non-associative array. - $results = array_values($results); - - // Push the results into cache. - $this->store($store, $results); - // Return the results. - return $this->retrieve($store); - } - - /** - * Method to get the total number of results. - * - * @return integer The total number of results. - * - * @since 2.5 - * @throws \Exception on database error. - */ - public function getTotal() - { - // Check if the search query is valid. - if (empty($this->query->search)) - { - return null; - } - - // Check if we should return results. - if (empty($this->includedTerms) && (empty($this->query->filters) || !$this->query->empty)) - { - return null; - } - - // Get the store id. - $store = $this->getStoreId('getTotal'); - - // Use the cached data if possible. - if ($this->retrieve($store)) - { - return $this->retrieve($store); - } - - // Get the results total. - $total = $this->getResultsTotal(); - - // Push the total into cache. - $this->store($store, $total); - - // Return the total. - return $this->retrieve($store); + return $results; } /** @@ -198,7 +115,7 @@ public function getTotal() public function getQuery() { // Return the query object. - return $this->query; + return $this->searchquery; } /** @@ -210,25 +127,25 @@ public function getQuery() */ protected function getListQuery() { - // Get the store id. - $store = $this->getStoreId('getListQuery'); - - // Use the cached data if possible. - if ($this->retrieve($store, false)) - { - return clone $this->retrieve($store, false); - } - - // Set variables + // Get the current user for authorisation checks $user = \JFactory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); // Create a new query object. - $db = $this->getDbo(); - $query = $db->getQuery(true) - ->select('l.link_id') - ->from($db->quoteName('#__finder_links') . ' AS l') - ->where('l.access IN (' . $groups . ')') + $db = $this->getDbo(); + $query = $db->getQuery(true); + + // Select the required fields from the table. + $query->select( + $this->getState( + 'list.select', + 'l.link_id, l.object' + ) + ); + + $query->from('#__finder_links AS l'); + + $query->where('l.access IN (' . $groups . ')') ->where('l.state = 1') ->where('l.published = 1'); @@ -240,16 +157,19 @@ protected function getListQuery() $query->where('(l.publish_start_date = ' . $nullDate . ' OR l.publish_start_date <= ' . $nowDate . ')') ->where('(l.publish_end_date = ' . $nullDate . ' OR l.publish_end_date >= ' . $nowDate . ')'); + $query->group('l.link_id'); + $query->group('l.object'); + /* * Add the taxonomy filters to the query. We have to join the taxonomy * map table for each group so that we can use AND clauses across * groups. Within each group there can be an array of values that will * use OR clauses. */ - if (!empty($this->query->filters)) + if (!empty($this->searchquery->filters)) { // Convert the associative array to a numerically indexed array. - $groups = array_values($this->query->filters); + $groups = array_values($this->searchquery->filters); // Iterate through each taxonomy group and add the join and where. for ($i = 0, $c = count($groups); $i < $c; $i++) @@ -261,17 +181,17 @@ protected function getListQuery() } // Add the start date filter to the query. - if (!empty($this->query->date1)) + if (!empty($this->searchquery->date1)) { // Escape the date. - $date1 = $db->quote($this->query->date1); + $date1 = $db->quote($this->searchquery->date1); // Add the appropriate WHERE condition. - if ($this->query->when1 === 'before') + if ($this->searchquery->when1 === 'before') { $query->where($db->quoteName('l.start_date') . ' <= ' . $date1); } - elseif ($this->query->when1 === 'after') + elseif ($this->searchquery->when1 === 'after') { $query->where($db->quoteName('l.start_date') . ' >= ' . $date1); } @@ -282,17 +202,17 @@ protected function getListQuery() } // Add the end date filter to the query. - if (!empty($this->query->date2)) + if (!empty($this->searchquery->date2)) { // Escape the date. - $date2 = $db->quote($this->query->date2); + $date2 = $db->quote($this->searchquery->date2); // Add the appropriate WHERE condition. - if ($this->query->when2 === 'before') + if ($this->searchquery->when2 === 'before') { $query->where($db->quoteName('l.start_date') . ' <= ' . $date2); } - elseif ($this->query->when2 === 'after') + elseif ($this->searchquery->when2 === 'after') { $query->where($db->quoteName('l.start_date') . ' >= ' . $date2); } @@ -301,326 +221,46 @@ protected function getListQuery() $query->where($db->quoteName('l.start_date') . ' = ' . $date2); } } - // Filter by language if ($this->getState('filter.language')) { $query->where('l.language IN (' . $db->quote(\JFactory::getLanguage()->getTag()) . ', ' . $db->quote('*') . ')'); } - // Push the data into cache. - $this->store($store, $query, false); - - // Return a copy of the query object. - return clone $this->retrieve($store, false); - } - - /** - * Method to get the total number of results for the search query. - * - * @return integer The results total. - * - * @since 2.5 - * @throws \Exception on database error. - */ - protected function getResultsTotal() - { - // Get the store id. - $store = $this->getStoreId('getResultsTotal', false); - - // Use the cached data if possible. - if ($this->retrieve($store)) - { - return $this->retrieve($store); - } - - // Get the base query and add the ordering information. - $base = $this->getListQuery(); - $base->select('0 AS ordering'); - - // Get the maximum number of results. - $limit = (int) $this->getState('match.limit'); + // Get the result ordering and direction. + $ordering = $this->getState('list.ordering', 'l.start_date'); + $direction = $this->getState('list.direction', 'DESC'); /* - * If there are no optional or required search terms in the query, - * we can get the result total in one relatively simple database query. + * If we are ordering by relevance we have to add up the relevance + * scores that are contained in the ordering field. */ - if (empty($this->includedTerms)) + if ($ordering === 'm.weight') { - // Adjust the query to join on the appropriate mapping table. - $query = clone $base; - $query->clear('select') - ->select('COUNT(DISTINCT l.link_id)'); - - // Get the total from the database. - $this->_db->setQuery($query); - $total = $this->_db->loadResult(); - - // Push the total into cache. - $this->store($store, min($total, $limit)); - - // Return the total. - return $this->retrieve($store); + // Get the base query and add the ordering information. + $query->select('SUM(' . $db->escape($ordering) . ') AS ordering'); + $query->order('ordering ' . $db->escape($direction)); } - /* - * If there are optional or required search terms in the query, the - * process of getting the result total is more complicated. + * If we are ordering by start date we have to add convert the + * dates to unix timestamps. */ - $start = 0; - $items = array(); - $sorted = array(); - $maps = array(); - $excluded = $this->getExcludedLinkIds(); - - /* - * Iterate through the included search terms and group them by mapping - * table suffix. This ensures that we never have to do more than 16 - * queries to get a batch. This may seem like a lot but it is rarely - * anywhere near 16 because of the improved mapping algorithm. - */ - foreach ($this->includedTerms as $token => $ids) + elseif ($ordering === 'l.start_date') { - // Get the mapping table suffix. - $suffix = StringHelper::substr(md5(StringHelper::substr($token, 0, 1)), 0, 1); - - // Initialize the mapping group. - if (!array_key_exists($suffix, $maps)) - { - $maps[$suffix] = array(); - } - - // Add the terms to the mapping group. - $maps[$suffix] = array_merge($maps[$suffix], $ids); + // Get the base query and add the ordering information. + $query->select($db->escape($ordering) . ' AS ordering'); + $query->order($db->escape($ordering) . ' ' . $db->escape($direction)); } - /* - * When the query contains search terms we need to find and process the - * result total iteratively using a do-while loop. + * If we are not ordering by relevance or date, we just have to add + * the unique items to the set. */ - do + else { - // Create a container for the fetched results. - $results = array(); - $more = false; - - /* - * Iterate through the mapping groups and load the total from each - * mapping table. - */ - foreach ($maps as $suffix => $ids) - { - // Create a storage key for this set. - $setId = $this->getStoreId('getResultsTotal:' . serialize(array_values($ids)) . ':' . $start . ':' . $limit); - - // Use the cached data if possible. - if ($this->retrieve($setId)) - { - $temp = $this->retrieve($setId); - } - // Load the data from the database. - else - { - // Adjust the query to join on the appropriate mapping table. - $query = clone $base; - $query->join('INNER', '#__finder_links_terms' . $suffix . ' AS m ON m.link_id = l.link_id') - ->where('m.term_id IN (' . implode(',', $ids) . ')'); - - // Load the results from the database. - $this->_db->setQuery($query, $start, $limit); - $temp = $this->_db->loadObjectList(); - - // Set the more flag to true if any of the sets equal the limit. - $more = count($temp) === $limit; - - // We loaded the data unkeyed but we need it to be keyed for later. - $junk = $temp; - $temp = array(); - - // Convert to an associative array. - for ($i = 0, $c = count($junk); $i < $c; $i++) - { - $temp[$junk[$i]->link_id] = $junk[$i]; - } - - // Store this set in cache. - $this->store($setId, $temp); - } - - // Merge the results. - $results = array_merge($results, $temp); - } - - // Check if there are any excluded terms to deal with. - if (count($excluded)) - { - // Remove any results that match excluded terms. - for ($i = 0, $c = count($results); $i < $c; $i++) - { - if (in_array($results[$i]->link_id, $excluded)) - { - unset($results[$i]); - } - } - - // Reset the array keys. - $results = array_values($results); - } - - // Iterate through the set to extract the unique items. - for ($i = 0, $c = count($results); $i < $c; $i++) - { - if (!isset($sorted[$results[$i]->link_id])) - { - $sorted[$results[$i]->link_id] = $results[$i]->ordering; - } - } - - /* - * If the query contains just optional search terms and we have - * enough items for the page, we can stop here. - */ - if (empty($this->requiredTerms)) - { - // If we need more items and they're available, make another pass. - if ($more && count($sorted) < $limit) - { - // Increment the batch starting point and continue. - $start += $limit; - continue; - } - - // Push the total into cache. - $this->store($store, min(count($sorted), $limit)); - - // Return the total. - return $this->retrieve($store); - } - - /* - * The query contains required search terms so we have to iterate - * over the items and remove any items that do not match all of the - * required search terms. This is one of the most expensive steps - * because a required token could theoretically eliminate all of - * current terms which means we would have to loop through all of - * the possibilities. - */ - foreach ($this->requiredTerms as $token => $required) - { - // Create a storage key for this set. - $setId = $this->getStoreId('getResultsTotal:required:' . serialize(array_values($required)) . ':' . $start . ':' . $limit); - - // Use the cached data if possible. - if ($this->retrieve($setId)) - { - $reqTemp = $this->retrieve($setId); - } - // Check if the token was matched. - elseif (empty($required)) - { - return null; - } - // Load the data from the database. - else - { - // Setup containers in case we have to make multiple passes. - $reqStart = 0; - $reqTemp = array(); - - do - { - // Get the map table suffix. - $suffix = StringHelper::substr(md5(StringHelper::substr($token, 0, 1)), 0, 1); - - // Adjust the query to join on the appropriate mapping table. - $query = clone $base; - $query->join('INNER', '#__finder_links_terms' . $suffix . ' AS m ON m.link_id = l.link_id') - ->where('m.term_id IN (' . implode(',', $required) . ')'); - - // Load the results from the database. - $this->_db->setQuery($query, $reqStart, $limit); - $temp = $this->_db->loadObjectList('link_id'); - - // Set the required token more flag to true if the set equal the limit. - $reqMore = count($temp) === $limit; - - // Merge the matching set for this token. - $reqTemp += $temp; - - // Increment the term offset. - $reqStart += $limit; - } - while ($reqMore === true); - - // Store this set in cache. - $this->store($setId, $reqTemp); - } - - // Remove any items that do not match the required term. - $sorted = array_intersect_key($sorted, $reqTemp); - } - - // If we need more items and they're available, make another pass. - if ($more && count($sorted) < $limit) - { - // Increment the batch starting point. - $start += $limit; - - // Merge the found items. - $items += $sorted; - - continue; - } - - // Otherwise, end the loop. - { - // Merge the found items. - $items += $sorted; - - $more = false; - } - // End do-while loop. + // Get the base query and add the ordering information. + $query->select($db->escape($ordering) . ' AS ordering'); + $query->order($db->escape($ordering) . ' ' . $db->escape($direction)); } - while ($more === true); - - // Set the total. - $total = count($items); - $total = min($total, $limit); - - // Push the total into cache. - $this->store($store, $total); - - // Return the total. - return $this->retrieve($store); - } - - /** - * Method to get the results for the search query. - * - * @return array An array of result data objects. - * - * @since 2.5 - * @throws \Exception on database error. - */ - protected function getResultsData() - { - // Get the store id. - $store = $this->getStoreId('getResultsData', false); - - // Use the cached data if possible. - if ($this->retrieve($store)) - { - return $this->retrieve($store); - } - - // Get the result ordering and direction. - $ordering = $this->getState('list.ordering', 'l.start_date'); - $direction = $this->getState('list.direction', 'DESC'); - - // Get the base query and add the ordering information. - $base = $this->getListQuery(); - $base->select($this->_db->escape($ordering) . ' AS ordering'); - $base->order($this->_db->escape($ordering) . ' ' . $this->_db->escape($direction)); /* * If there are no optional or required search terms in the query, we @@ -628,376 +268,36 @@ protected function getResultsData() */ if (empty($this->includedTerms)) { - // Get the results from the database. - $this->_db->setQuery($base, (int) $this->getState('list.start'), (int) $this->getState('list.limit')); - $return = $this->_db->loadObjectList('link_id'); - - // Get a new store id because this data is page specific. - $store = $this->getStoreId('getResultsData', true); - - // Push the results into cache. - $this->store($store, $return); - // Return the results. - return $this->retrieve($store); + return $query; } - /* - * If there are optional or required search terms in the query, the - * process of getting the results is more complicated. - */ - $start = 0; - $limit = (int) $this->getState('match.limit'); - $items = array(); - $sorted = array(); - $maps = array(); - $excluded = $this->getExcludedLinkIds(); + $included = call_user_func_array('array_merge', $this->includedTerms); + $query->join('INNER', $this->_db->quoteName('#__finder_links_terms') . ' AS m ON m.link_id = l.link_id') + ->where('m.term_id IN (' . implode(',', $included) . ')'); - /* - * Iterate through the included search terms and group them by mapping - * table suffix. This ensures that we never have to do more than 16 - * queries to get a batch. This may seem like a lot but it is rarely - * anywhere near 16 because of the improved mapping algorithm. - */ - foreach ($this->includedTerms as $token => $ids) + // Check if there are any excluded terms to deal with. + if (count($this->excludedTerms)) { - // Get the mapping table suffix. - $suffix = StringHelper::substr(md5(StringHelper::substr($token, 0, 1)), 0, 1); - - // Initialize the mapping group. - if (!array_key_exists($suffix, $maps)) - { - $maps[$suffix] = array(); - } - - // Add the terms to the mapping group. - $maps[$suffix] = array_merge($maps[$suffix], $ids); + $query2 = $db->getQuery(true); + $query2->select('e.link_id') + ->from($this->_db->quoteName('#__finder_links_terms', 'e')) + ->where('e.term_id IN (' . implode(',', $this->excludedTerms) . ')'); + $query->where('l.link_id NOT IN (' . $query2 . ')'); } /* - * When the query contains search terms we need to find and process the - * results iteratively using a do-while loop. + * The query contains required search terms. */ - do + if (count($this->requiredTerms)) { - // Create a container for the fetched results. - $results = array(); - $more = false; - - /* - * Iterate through the mapping groups and load the results from each - * mapping table. - */ - foreach ($maps as $suffix => $ids) - { - // Create a storage key for this set. - $setId = $this->getStoreId('getResultsData:' . serialize(array_values($ids)) . ':' . $start . ':' . $limit); - - // Use the cached data if possible. - if ($this->retrieve($setId)) - { - $temp = $this->retrieve($setId); - } - // Load the data from the database. - else - { - // Adjust the query to join on the appropriate mapping table. - $query = clone $base; - $query->join('INNER', $this->_db->quoteName('#__finder_links_terms' . $suffix) . ' AS m ON m.link_id = l.link_id') - ->where('m.term_id IN (' . implode(',', $ids) . ')'); - - // Load the results from the database. - $this->_db->setQuery($query, $start, $limit); - $temp = $this->_db->loadObjectList('link_id'); - - // Store this set in cache. - $this->store($setId, $temp); - - // The data is keyed by link_id to ease caching, we don't need it till later. - $temp = array_values($temp); - } - - // Set the more flag to true if any of the sets equal the limit. - $more = count($temp) === $limit; - - // Merge the results. - $results = array_merge($results, $temp); - } - - // Check if there are any excluded terms to deal with. - if (count($excluded)) - { - // Remove any results that match excluded terms. - for ($i = 0, $c = count($results); $i < $c; $i++) - { - if (in_array($results[$i]->link_id, $excluded)) - { - unset($results[$i]); - } - } - - // Reset the array keys. - $results = array_values($results); - } - - /* - * If we are ordering by relevance we have to add up the relevance - * scores that are contained in the ordering field. - */ - if ($ordering === 'm.weight') - { - // Iterate through the set to extract the unique items. - for ($i = 0, $c = count($results); $i < $c; $i++) - { - // Add the total weights for all included search terms. - if (isset($sorted[$results[$i]->link_id])) - { - $sorted[$results[$i]->link_id] += (float) $results[$i]->ordering; - } - else - { - $sorted[$results[$i]->link_id] = (float) $results[$i]->ordering; - } - } - } - /* - * If we are ordering by start date we have to add convert the - * dates to unix timestamps. - */ - elseif ($ordering === 'l.start_date') - { - // Iterate through the set to extract the unique items. - for ($i = 0, $c = count($results); $i < $c; $i++) - { - if (!isset($sorted[$results[$i]->link_id])) - { - $sorted[$results[$i]->link_id] = strtotime($results[$i]->ordering); - } - } - } - /* - * If we are not ordering by relevance or date, we just have to add - * the unique items to the set. - */ - else - { - // Iterate through the set to extract the unique items. - for ($i = 0, $c = count($results); $i < $c; $i++) - { - if (!isset($sorted[$results[$i]->link_id])) - { - $sorted[$results[$i]->link_id] = $results[$i]->ordering; - } - } - } - - // Sort the results. - natcasesort($items); - - if ($direction === 'DESC') - { - $items = array_reverse($items, true); - } - - /* - * If the query contains just optional search terms and we have - * enough items for the page, we can stop here. - */ - if (empty($this->requiredTerms)) - { - // If we need more items and they're available, make another pass. - if ($more && count($sorted) < ($this->getState('list.start') + $this->getState('list.limit'))) - { - // Increment the batch starting point and continue. - $start += $limit; - continue; - } - - // Push the results into cache. - $this->store($store, $sorted); - - // Return the requested set. - return array_slice($this->retrieve($store), (int) $this->getState('list.start'), (int) $this->getState('list.limit'), true); - } - - /* - * The query contains required search terms so we have to iterate - * over the items and remove any items that do not match all of the - * required search terms. This is one of the most expensive steps - * because a required token could theoretically eliminate all of - * current terms which means we would have to loop through all of - * the possibilities. - */ - foreach ($this->requiredTerms as $token => $required) - { - // Create a storage key for this set. - $setId = $this->getStoreId('getResultsData:required:' . serialize(array_values($required)) . ':' . $start . ':' . $limit); - - // Use the cached data if possible. - if ($this->retrieve($setId)) - { - $reqTemp = $this->retrieve($setId); - } - // Check if the token was matched. - elseif (empty($required)) - { - return null; - } - // Load the data from the database. - else - { - // Setup containers in case we have to make multiple passes. - $reqStart = 0; - $reqTemp = array(); - - do - { - // Get the map table suffix. - $suffix = StringHelper::substr(md5(StringHelper::substr($token, 0, 1)), 0, 1); - - // Adjust the query to join on the appropriate mapping table. - $query = clone $base; - $query->join('INNER', $this->_db->quoteName('#__finder_links_terms' . $suffix) . ' AS m ON m.link_id = l.link_id') - ->where('m.term_id IN (' . implode(',', $required) . ')'); - - // Load the results from the database. - $this->_db->setQuery($query, $reqStart, $limit); - $temp = $this->_db->loadObjectList('link_id'); - - // Set the required token more flag to true if the set equal the limit. - $reqMore = count($temp) === $limit; - - // Merge the matching set for this token. - $reqTemp += $temp; - - // Increment the term offset. - $reqStart += $limit; - } - while ($reqMore === true); - - // Store this set in cache. - $this->store($setId, $reqTemp); - } - - // Remove any items that do not match the required term. - $sorted = array_intersect_key($sorted, $reqTemp); - } - - // If we need more items and they're available, make another pass. - if ($more && count($sorted) < ($this->getState('list.start') + $this->getState('list.limit'))) - { - // Increment the batch starting point. - $start += $limit; - - // Merge the found items. - $items = array_merge($items, $sorted); - - continue; - } - // Otherwise, end the loop. - else - { - // Set the found items. - $items = $sorted; - - $more = false; - } - - // End do-while loop. + $required = call_user_func_array('array_merge', $this->requiredTerms); + $query->join('INNER', $this->_db->quoteName('#__finder_links_terms') . ' AS r ON r.link_id = l.link_id') + ->where('r.term_id IN (' . implode(',', $required) . ')') + ->having('COUNT(DISTINCT r.term_id) = ' . count($required)); } - while ($more === true); - - // Push the results into cache. - $this->store($store, $items); - // Return the requested set. - return array_slice($this->retrieve($store), (int) $this->getState('list.start'), (int) $this->getState('list.limit'), true); - } - - /** - * Method to get an array of link ids that match excluded terms. - * - * @return array An array of links ids. - * - * @since 2.5 - * @throws \Exception on database error. - */ - protected function getExcludedLinkIds() - { - // Check if the search query has excluded terms. - if (empty($this->excludedTerms)) - { - return array(); - } - - // Get the store id. - $store = $this->getStoreId('getExcludedLinkIds', false); - - // Use the cached data if possible. - if ($this->retrieve($store)) - { - return $this->retrieve($store); - } - - // Initialize containers. - $links = array(); - $maps = array(); - - /* - * Iterate through the excluded search terms and group them by mapping - * table suffix. This ensures that we never have to do more than 16 - * queries to get a batch. This may seem like a lot but it is rarely - * anywhere near 16 because of the improved mapping algorithm. - */ - foreach ($this->excludedTerms as $token => $id) - { - // Get the mapping table suffix. - $suffix = StringHelper::substr(md5(StringHelper::substr($token, 0, 1)), 0, 1); - - // Initialize the mapping group. - if (!array_key_exists($suffix, $maps)) - { - $maps[$suffix] = array(); - } - - // Add the terms to the mapping group. - $maps[$suffix][] = (int) $id; - } - - /* - * Iterate through the mapping groups and load the excluded links ids - * from each mapping table. - */ - - // Create a new query object. - $db = $this->getDbo(); - $query = $db->getQuery(true); - - foreach ($maps as $suffix => $ids) - { - // Create the query to get the links ids. - $query->clear() - ->select('link_id') - ->from($db->quoteName('#__finder_links_terms' . $suffix)) - ->where($db->quoteName('term_id') . ' IN (' . implode(',', $ids) . ')') - ->group($db->quoteName('link_id')); - - // Load the link ids from the database. - $db->setQuery($query); - $temp = $db->loadColumn(); - - // Merge the link ids. - $links = array_merge($links, $temp); - } - - // Sanitize the link ids. - $links = array_unique($links); - $links = ArrayHelper::toInteger($links); - - // Push the link ids into cache. - $this->store($store, $links); - - return $links; + return $query; } /** @@ -1094,19 +394,18 @@ protected function populateState($ordering = null, $direction = null) $options['when2'] = $request->getString('w2', $params->get('w2', '')); // Load the query object. - $this->query = new \FinderIndexerQuery($options); + $this->searchquery = new \FinderIndexerQuery($options); // Load the query token data. - $this->excludedTerms = $this->query->getExcludedTermIds(); - $this->includedTerms = $this->query->getIncludedTermIds(); - $this->requiredTerms = $this->query->getRequiredTermIds(); + $this->excludedTerms = $this->searchquery->getExcludedTermIds(); + $this->includedTerms = $this->searchquery->getIncludedTermIds(); + $this->requiredTerms = $this->searchquery->getRequiredTermIds(); // Load the list state. $this->setState('list.start', $input->get('limitstart', 0, 'uint')); $this->setState('list.limit', $input->get('limit', $app->get('list_limit', 20), 'uint')); - /** - * Load the sort ordering. + /* Load the sort ordering. * Currently this is 'hard' coded via menu item parameter but may not satisfy a users need. * More flexibility was way more user friendly. So we allow the user to pass a custom value * from the pool of fields that are indexed like the 'title' field. @@ -1114,7 +413,6 @@ protected function populateState($ordering = null, $direction = null) */ $order = $input->getWord('filter_order', $params->get('sort_order', 'relevance')); $order = StringHelper::strtolower($order); - switch ($order) { case 'date': @@ -1139,15 +437,13 @@ protected function populateState($ordering = null, $direction = null) break; } - /** - * Load the sort direction. + /* Load the sort direction. * Currently this is 'hard' coded via menu item parameter but may not satisfy a users need. * More flexibility was way more user friendly. So we allow to be inverted. * Also, we allow this parameter to be passed in either case (lower/upper). */ $dirn = $input->getWord('filter_order_Dir', $params->get('sort_direction', 'desc')); $dirn = StringHelper::strtolower($dirn); - switch ($dirn) { case 'asc': diff --git a/components/com_finder/View/Search/HtmlView.php b/components/com_finder/View/Search/HtmlView.php index c4d0b5a4c31d3..0566d0d41e8cc 100644 --- a/components/com_finder/View/Search/HtmlView.php +++ b/components/com_finder/View/Search/HtmlView.php @@ -119,7 +119,7 @@ public function display($tpl = null) $state = $this->get('State'); $query = $this->get('Query'); \JDEBUG ? \JProfiler::getInstance('Application')->mark('afterFinderQuery') : null; - $results = $this->get('Results'); + $results = $this->get('Items'); \JDEBUG ? \JProfiler::getInstance('Application')->mark('afterFinderResults') : null; $total = $this->get('Total'); \JDEBUG ? \JProfiler::getInstance('Application')->mark('afterFinderTotal') : null; diff --git a/components/com_finder/helpers/html/filter.php b/components/com_finder/helpers/html/filter.php index 5fcb319a23afc..15b4f478abdc1 100644 --- a/components/com_finder/helpers/html/filter.php +++ b/components/com_finder/helpers/html/filter.php @@ -272,6 +272,8 @@ public static function select($idxQuery, $options) ->where('c.state = 1') ->where('c.access IN (' . $groups . ')') ->group($db->quoteName('t.id')) + ->group($db->quoteName('t.parent_id')) + ->group('t.title, t.state, t.access, t.ordering') ->order('t.ordering, t.title'); // Limit the branch children to a predefined filter. diff --git a/components/com_finder/helpers/html/query.php b/components/com_finder/helpers/html/query.php index 831b4f0c7c0cd..240e73f6ee1a9 100644 --- a/components/com_finder/helpers/html/query.php +++ b/components/com_finder/helpers/html/query.php @@ -9,6 +9,8 @@ defined('_JEXEC') or die; +JLoader::register('FinderHelperLanguage', JPATH_ADMINISTRATOR . '/components/com_finder/helpers/language.php'); + /** * Query HTML behavior class for Finder. * diff --git a/installation/sql/mysql/joomla.sql b/installation/sql/mysql/joomla.sql index 6f65619e1e6fc..acd2d17c8dd36 100644 --- a/installation/sql/mysql/joomla.sql +++ b/installation/sql/mysql/joomla.sql @@ -789,7 +789,7 @@ CREATE TABLE IF NOT EXISTS `#__finder_links` ( `published` tinyint(1) NOT NULL DEFAULT 1, `state` int(5) DEFAULT 1, `access` int(5) DEFAULT 0, - `language` varchar(8) NOT NULL, + `language` char(7) NOT NULL DEFAULT '', `publish_start_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `publish_end_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `start_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', @@ -810,235 +810,10 @@ CREATE TABLE IF NOT EXISTS `#__finder_links` ( -- -------------------------------------------------------- -- --- Table structure for table `#__finder_links_terms0` --- - -CREATE TABLE IF NOT EXISTS `#__finder_links_terms0` ( - `link_id` int(10) unsigned NOT NULL, - `term_id` int(10) unsigned NOT NULL, - `weight` float unsigned NOT NULL, - PRIMARY KEY (`link_id`,`term_id`), - KEY `idx_term_weight` (`term_id`,`weight`), - KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; - --- -------------------------------------------------------- - --- --- Table structure for table `#__finder_links_terms1` --- - -CREATE TABLE IF NOT EXISTS `#__finder_links_terms1` ( - `link_id` int(10) unsigned NOT NULL, - `term_id` int(10) unsigned NOT NULL, - `weight` float unsigned NOT NULL, - PRIMARY KEY (`link_id`,`term_id`), - KEY `idx_term_weight` (`term_id`,`weight`), - KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; - --- -------------------------------------------------------- - --- --- Table structure for table `#__finder_links_terms2` --- - -CREATE TABLE IF NOT EXISTS `#__finder_links_terms2` ( - `link_id` int(10) unsigned NOT NULL, - `term_id` int(10) unsigned NOT NULL, - `weight` float unsigned NOT NULL, - PRIMARY KEY (`link_id`,`term_id`), - KEY `idx_term_weight` (`term_id`,`weight`), - KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; - --- -------------------------------------------------------- - --- --- Table structure for table `#__finder_links_terms3` --- - -CREATE TABLE IF NOT EXISTS `#__finder_links_terms3` ( - `link_id` int(10) unsigned NOT NULL, - `term_id` int(10) unsigned NOT NULL, - `weight` float unsigned NOT NULL, - PRIMARY KEY (`link_id`,`term_id`), - KEY `idx_term_weight` (`term_id`,`weight`), - KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; - --- -------------------------------------------------------- - --- --- Table structure for table `#__finder_links_terms4` --- - -CREATE TABLE IF NOT EXISTS `#__finder_links_terms4` ( - `link_id` int(10) unsigned NOT NULL, - `term_id` int(10) unsigned NOT NULL, - `weight` float unsigned NOT NULL, - PRIMARY KEY (`link_id`,`term_id`), - KEY `idx_term_weight` (`term_id`,`weight`), - KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; - --- -------------------------------------------------------- - --- --- Table structure for table `#__finder_links_terms5` --- - -CREATE TABLE IF NOT EXISTS `#__finder_links_terms5` ( - `link_id` int(10) unsigned NOT NULL, - `term_id` int(10) unsigned NOT NULL, - `weight` float unsigned NOT NULL, - PRIMARY KEY (`link_id`,`term_id`), - KEY `idx_term_weight` (`term_id`,`weight`), - KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; - --- -------------------------------------------------------- - --- --- Table structure for table `#__finder_links_terms6` --- - -CREATE TABLE IF NOT EXISTS `#__finder_links_terms6` ( - `link_id` int(10) unsigned NOT NULL, - `term_id` int(10) unsigned NOT NULL, - `weight` float unsigned NOT NULL, - PRIMARY KEY (`link_id`,`term_id`), - KEY `idx_term_weight` (`term_id`,`weight`), - KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; - --- -------------------------------------------------------- - --- --- Table structure for table `#__finder_links_terms7` --- - -CREATE TABLE IF NOT EXISTS `#__finder_links_terms7` ( - `link_id` int(10) unsigned NOT NULL, - `term_id` int(10) unsigned NOT NULL, - `weight` float unsigned NOT NULL, - PRIMARY KEY (`link_id`,`term_id`), - KEY `idx_term_weight` (`term_id`,`weight`), - KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; - --- -------------------------------------------------------- - --- --- Table structure for table `#__finder_links_terms8` --- - -CREATE TABLE IF NOT EXISTS `#__finder_links_terms8` ( - `link_id` int(10) unsigned NOT NULL, - `term_id` int(10) unsigned NOT NULL, - `weight` float unsigned NOT NULL, - PRIMARY KEY (`link_id`,`term_id`), - KEY `idx_term_weight` (`term_id`,`weight`), - KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; - --- -------------------------------------------------------- - --- --- Table structure for table `#__finder_links_terms9` --- - -CREATE TABLE IF NOT EXISTS `#__finder_links_terms9` ( - `link_id` int(10) unsigned NOT NULL, - `term_id` int(10) unsigned NOT NULL, - `weight` float unsigned NOT NULL, - PRIMARY KEY (`link_id`,`term_id`), - KEY `idx_term_weight` (`term_id`,`weight`), - KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; - --- -------------------------------------------------------- - --- --- Table structure for table `#__finder_links_termsa` --- - -CREATE TABLE IF NOT EXISTS `#__finder_links_termsa` ( - `link_id` int(10) unsigned NOT NULL, - `term_id` int(10) unsigned NOT NULL, - `weight` float unsigned NOT NULL, - PRIMARY KEY (`link_id`,`term_id`), - KEY `idx_term_weight` (`term_id`,`weight`), - KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; - --- -------------------------------------------------------- - --- --- Table structure for table `#__finder_links_termsb` --- - -CREATE TABLE IF NOT EXISTS `#__finder_links_termsb` ( - `link_id` int(10) unsigned NOT NULL, - `term_id` int(10) unsigned NOT NULL, - `weight` float unsigned NOT NULL, - PRIMARY KEY (`link_id`,`term_id`), - KEY `idx_term_weight` (`term_id`,`weight`), - KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; - --- -------------------------------------------------------- - --- --- Table structure for table `#__finder_links_termsc` --- - -CREATE TABLE IF NOT EXISTS `#__finder_links_termsc` ( - `link_id` int(10) unsigned NOT NULL, - `term_id` int(10) unsigned NOT NULL, - `weight` float unsigned NOT NULL, - PRIMARY KEY (`link_id`,`term_id`), - KEY `idx_term_weight` (`term_id`,`weight`), - KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; - --- -------------------------------------------------------- - --- --- Table structure for table `#__finder_links_termsd` --- - -CREATE TABLE IF NOT EXISTS `#__finder_links_termsd` ( - `link_id` int(10) unsigned NOT NULL, - `term_id` int(10) unsigned NOT NULL, - `weight` float unsigned NOT NULL, - PRIMARY KEY (`link_id`,`term_id`), - KEY `idx_term_weight` (`term_id`,`weight`), - KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; - --- -------------------------------------------------------- - --- --- Table structure for table `#__finder_links_termse` +-- Table structure for table `#__finder_links_terms` -- -CREATE TABLE IF NOT EXISTS `#__finder_links_termse` ( - `link_id` int(10) unsigned NOT NULL, - `term_id` int(10) unsigned NOT NULL, - `weight` float unsigned NOT NULL, - PRIMARY KEY (`link_id`,`term_id`), - KEY `idx_term_weight` (`term_id`,`weight`), - KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; - --- -------------------------------------------------------- - --- --- Table structure for table `#__finder_links_termsf` --- - -CREATE TABLE IF NOT EXISTS `#__finder_links_termsf` ( +CREATE TABLE IF NOT EXISTS `#__finder_links_terms` ( `link_id` int(10) unsigned NOT NULL, `term_id` int(10) unsigned NOT NULL, `weight` float unsigned NOT NULL, @@ -1104,7 +879,7 @@ CREATE TABLE IF NOT EXISTS `#__finder_terms` ( `weight` float unsigned NOT NULL DEFAULT 0, `soundex` varchar(75) NOT NULL, `links` int(10) NOT NULL DEFAULT 0, - `language` char(3) NOT NULL DEFAULT '', + `language` char(7) NOT NULL DEFAULT '', PRIMARY KEY (`term_id`), UNIQUE KEY `idx_term` (`term`), KEY `idx_term_phrase` (`term`,`phrase`), @@ -1120,7 +895,7 @@ CREATE TABLE IF NOT EXISTS `#__finder_terms` ( CREATE TABLE IF NOT EXISTS `#__finder_terms_common` ( `term` varchar(75) NOT NULL, - `language` varchar(3) NOT NULL, + `language` char(7) NOT NULL DEFAULT '', KEY `idx_word_lang` (`term`,`language`), KEY `idx_lang` (`language`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; @@ -1130,116 +905,116 @@ CREATE TABLE IF NOT EXISTS `#__finder_terms_common` ( -- INSERT INTO `#__finder_terms_common` (`term`, `language`) VALUES -('a', 'en'), -('about', 'en'), -('after', 'en'), -('ago', 'en'), -('all', 'en'), -('am', 'en'), -('an', 'en'), -('and', 'en'), -('any', 'en'), -('are', 'en'), -('aren''t', 'en'), -('as', 'en'), -('at', 'en'), -('be', 'en'), -('but', 'en'), -('by', 'en'), -('for', 'en'), -('from', 'en'), -('get', 'en'), -('go', 'en'), -('how', 'en'), -('if', 'en'), -('in', 'en'), -('into', 'en'), -('is', 'en'), -('isn''t', 'en'), -('it', 'en'), -('its', 'en'), -('me', 'en'), -('more', 'en'), -('most', 'en'), -('must', 'en'), -('my', 'en'), -('new', 'en'), -('no', 'en'), -('none', 'en'), -('not', 'en'), -('nothing', 'en'), -('of', 'en'), -('off', 'en'), -('often', 'en'), -('old', 'en'), -('on', 'en'), -('onc', 'en'), -('once', 'en'), -('only', 'en'), -('or', 'en'), -('other', 'en'), -('our', 'en'), -('ours', 'en'), -('out', 'en'), -('over', 'en'), -('page', 'en'), -('she', 'en'), -('should', 'en'), -('small', 'en'), -('so', 'en'), -('some', 'en'), -('than', 'en'), -('thank', 'en'), -('that', 'en'), -('the', 'en'), -('their', 'en'), -('theirs', 'en'), -('them', 'en'), -('then', 'en'), -('there', 'en'), -('these', 'en'), -('they', 'en'), -('this', 'en'), -('those', 'en'), -('thus', 'en'), -('time', 'en'), -('times', 'en'), -('to', 'en'), -('too', 'en'), -('true', 'en'), -('under', 'en'), -('until', 'en'), -('up', 'en'), -('upon', 'en'), -('use', 'en'), -('user', 'en'), -('users', 'en'), -('version', 'en'), -('very', 'en'), -('via', 'en'), -('want', 'en'), -('was', 'en'), -('way', 'en'), -('were', 'en'), -('what', 'en'), -('when', 'en'), -('where', 'en'), -('which', 'en'), -('who', 'en'), -('whom', 'en'), -('whose', 'en'), -('why', 'en'), -('wide', 'en'), -('will', 'en'), -('with', 'en'), -('within', 'en'), -('without', 'en'), -('would', 'en'), -('yes', 'en'), -('yet', 'en'), -('you', 'en'), -('your', 'en'), -('yours', 'en'); +('a', 'en-GB'), +('about', 'en-GB'), +('after', 'en-GB'), +('ago', 'en-GB'), +('all', 'en-GB'), +('am', 'en-GB'), +('an', 'en-GB'), +('and', 'en-GB'), +('any', 'en-GB'), +('are', 'en-GB'), +('aren''t', 'en-GB'), +('as', 'en-GB'), +('at', 'en-GB'), +('be', 'en-GB'), +('but', 'en-GB'), +('by', 'en-GB'), +('for', 'en-GB'), +('from', 'en-GB'), +('get', 'en-GB'), +('go', 'en-GB'), +('how', 'en-GB'), +('if', 'en-GB'), +('in', 'en-GB'), +('into', 'en-GB'), +('is', 'en-GB'), +('isn''t', 'en-GB'), +('it', 'en-GB'), +('its', 'en-GB'), +('me', 'en-GB'), +('more', 'en-GB'), +('most', 'en-GB'), +('must', 'en-GB'), +('my', 'en-GB'), +('new', 'en-GB'), +('no', 'en-GB'), +('none', 'en-GB'), +('not', 'en-GB'), +('nothing', 'en-GB'), +('of', 'en-GB'), +('off', 'en-GB'), +('often', 'en-GB'), +('old', 'en-GB'), +('on', 'en-GB'), +('onc', 'en-GB'), +('once', 'en-GB'), +('only', 'en-GB'), +('or', 'en-GB'), +('other', 'en-GB'), +('our', 'en-GB'), +('ours', 'en-GB'), +('out', 'en-GB'), +('over', 'en-GB'), +('page', 'en-GB'), +('she', 'en-GB'), +('should', 'en-GB'), +('small', 'en-GB'), +('so', 'en-GB'), +('some', 'en-GB'), +('than', 'en-GB'), +('thank', 'en-GB'), +('that', 'en-GB'), +('the', 'en-GB'), +('their', 'en-GB'), +('theirs', 'en-GB'), +('them', 'en-GB'), +('then', 'en-GB'), +('there', 'en-GB'), +('these', 'en-GB'), +('they', 'en-GB'), +('this', 'en-GB'), +('those', 'en-GB'), +('thus', 'en-GB'), +('time', 'en-GB'), +('times', 'en-GB'), +('to', 'en-GB'), +('too', 'en-GB'), +('true', 'en-GB'), +('under', 'en-GB'), +('until', 'en-GB'), +('up', 'en-GB'), +('upon', 'en-GB'), +('use', 'en-GB'), +('user', 'en-GB'), +('users', 'en-GB'), +('version', 'en-GB'), +('very', 'en-GB'), +('via', 'en-GB'), +('want', 'en-GB'), +('was', 'en-GB'), +('way', 'en-GB'), +('were', 'en-GB'), +('what', 'en-GB'), +('when', 'en-GB'), +('where', 'en-GB'), +('which', 'en-GB'), +('who', 'en-GB'), +('whom', 'en-GB'), +('whose', 'en-GB'), +('why', 'en-GB'), +('wide', 'en-GB'), +('will', 'en-GB'), +('with', 'en-GB'), +('within', 'en-GB'), +('without', 'en-GB'), +('would', 'en-GB'), +('yes', 'en-GB'), +('yet', 'en-GB'), +('you', 'en-GB'), +('your', 'en-GB'), +('yours', 'en-GB'); -- -------------------------------------------------------- @@ -1254,7 +1029,7 @@ CREATE TABLE IF NOT EXISTS `#__finder_tokens` ( `phrase` tinyint(1) unsigned NOT NULL DEFAULT 0, `weight` float unsigned NOT NULL DEFAULT 1, `context` tinyint(1) unsigned NOT NULL DEFAULT 2, - `language` char(3) NOT NULL DEFAULT '', + `language` char(7) NOT NULL DEFAULT '', KEY `idx_word` (`term`), KEY `idx_context` (`context`) ) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; @@ -1267,7 +1042,6 @@ CREATE TABLE IF NOT EXISTS `#__finder_tokens` ( CREATE TABLE IF NOT EXISTS `#__finder_tokens_aggregate` ( `term_id` int(10) unsigned NOT NULL, - `map_suffix` char(1) NOT NULL, `term` varchar(75) NOT NULL, `stem` varchar(75) NOT NULL, `common` tinyint(1) unsigned NOT NULL DEFAULT 0, @@ -1276,7 +1050,7 @@ CREATE TABLE IF NOT EXISTS `#__finder_tokens_aggregate` ( `context` tinyint(1) unsigned NOT NULL DEFAULT 2, `context_weight` float unsigned NOT NULL, `total_weight` float unsigned NOT NULL, - `language` char(3) NOT NULL DEFAULT '', + `language` char(7) NOT NULL DEFAULT '', KEY `token` (`term`), KEY `keyword_id` (`term_id`) ) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; @@ -1328,7 +1102,7 @@ CREATE TABLE IF NOT EXISTS `#__languages` ( -- INSERT INTO `#__languages` (`lang_id`, `lang_code`, `title`, `title_native`, `sef`, `image`, `description`, `metakey`, `metadesc`, `sitename`, `published`, `access`, `ordering`) VALUES -(1, 'en-GB', 'English (en-GB)', 'English (United Kingdom)', 'en', 'en_gb', '', '', '', '', 1, 1, 1); +(1, 'en-GB', 'English (en-GB)', 'English (United Kingdom)', 'en-GB', 'en_gb', '', '', '', '', 1, 1, 1); -- -------------------------------------------------------- diff --git a/installation/sql/postgresql/joomla.sql b/installation/sql/postgresql/joomla.sql index c6369bc3b3f53..4f35c4e20cd51 100644 --- a/installation/sql/postgresql/joomla.sql +++ b/installation/sql/postgresql/joomla.sql @@ -793,7 +793,7 @@ CREATE TABLE IF NOT EXISTS "#__finder_links" ( "published" smallint DEFAULT 1 NOT NULL, "state" integer DEFAULT 1, "access" integer DEFAULT 0, - "language" varchar(8) DEFAULT '' NOT NULL, + "language" varchar(7) DEFAULT '' NOT NULL, "publish_start_date" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL, "publish_end_date" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL, "start_date" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL, @@ -812,212 +812,17 @@ CREATE INDEX "#__finder_links_idx_published_list" on "#__finder_links" ("publish CREATE INDEX "#__finder_links_idx_published_sale" on "#__finder_links" ("published", "state", "access", "publish_start_date", "publish_end_date", "sale_price"); -- --- Table structure for table `#__finder_links_terms0` --- - -CREATE TABLE IF NOT EXISTS "#__finder_links_terms0" ( - "link_id" integer NOT NULL, - "term_id" integer NOT NULL, - "weight" numeric(8,2) NOT NULL, - PRIMARY KEY ("link_id", "term_id") -); -CREATE INDEX "#__finder_links_terms0_idx_term_weight" on "#__finder_links_terms0" ("term_id", "weight"); -CREATE INDEX "#__finder_links_terms0_idx_link_term_weight" on "#__finder_links_terms0" ("link_id", "term_id", "weight"); - --- --- Table structure for table `#__finder_links_terms1` +-- Table structure for table `#__finder_links_terms` -- -CREATE TABLE IF NOT EXISTS "#__finder_links_terms1" ( +CREATE TABLE IF NOT EXISTS "#__finder_links_terms" ( "link_id" integer NOT NULL, "term_id" integer NOT NULL, "weight" numeric(8,2) NOT NULL, PRIMARY KEY ("link_id", "term_id") ); -CREATE INDEX "#__finder_links_terms1_idx_term_weight" on "#__finder_links_terms1" ("term_id", "weight"); -CREATE INDEX "#__finder_links_terms1_idx_link_term_weight" on "#__finder_links_terms1" ("link_id", "term_id", "weight"); - --- --- Table structure for table `#__finder_links_terms2` --- - -CREATE TABLE IF NOT EXISTS "#__finder_links_terms2" ( - "link_id" integer NOT NULL, - "term_id" integer NOT NULL, - "weight" numeric(8,2) NOT NULL, - PRIMARY KEY ("link_id", "term_id") -); -CREATE INDEX "#__finder_links_terms2_idx_term_weight" on "#__finder_links_terms2" ("term_id", "weight"); -CREATE INDEX "#__finder_links_terms2_idx_link_term_weight" on "#__finder_links_terms2" ("link_id", "term_id", "weight"); - --- --- Table structure for table `#__finder_links_terms3` --- - -CREATE TABLE IF NOT EXISTS "#__finder_links_terms3" ( - "link_id" integer NOT NULL, - "term_id" integer NOT NULL, - "weight" numeric(8,2) NOT NULL, - PRIMARY KEY ("link_id", "term_id") -); -CREATE INDEX "#__finder_links_terms3_idx_term_weight" on "#__finder_links_terms3" ("term_id", "weight"); -CREATE INDEX "#__finder_links_terms3_idx_link_term_weight" on "#__finder_links_terms3" ("link_id", "term_id", "weight"); - --- --- Table structure for table `#__finder_links_terms4` --- - -CREATE TABLE IF NOT EXISTS "#__finder_links_terms4" ( - "link_id" integer NOT NULL, - "term_id" integer NOT NULL, - "weight" numeric(8,2) NOT NULL, - PRIMARY KEY ("link_id", "term_id") -); -CREATE INDEX "#__finder_links_terms4_idx_term_weight" on "#__finder_links_terms4" ("term_id", "weight"); -CREATE INDEX "#__finder_links_terms4_idx_link_term_weight" on "#__finder_links_terms4" ("link_id", "term_id", "weight"); - --- --- Table structure for table `#__finder_links_terms5` --- - -CREATE TABLE IF NOT EXISTS "#__finder_links_terms5" ( - "link_id" integer NOT NULL, - "term_id" integer NOT NULL, - "weight" numeric(8,2) NOT NULL, - PRIMARY KEY ("link_id", "term_id") -); -CREATE INDEX "#__finder_links_terms5_idx_term_weight" on "#__finder_links_terms5" ("term_id", "weight"); -CREATE INDEX "#__finder_links_terms5_idx_link_term_weight" on "#__finder_links_terms5" ("link_id", "term_id", "weight"); - --- --- Table structure for table `#__finder_links_terms6` --- - -CREATE TABLE IF NOT EXISTS "#__finder_links_terms6" ( - "link_id" integer NOT NULL, - "term_id" integer NOT NULL, - "weight" numeric(8,2) NOT NULL, - PRIMARY KEY ("link_id", "term_id") -); -CREATE INDEX "#__finder_links_terms6_idx_term_weight" on "#__finder_links_terms6" ("term_id", "weight"); -CREATE INDEX "#__finder_links_terms6_idx_link_term_weight" on "#__finder_links_terms6" ("link_id", "term_id", "weight"); - --- --- Table structure for table `#__finder_links_terms7` --- - -CREATE TABLE IF NOT EXISTS "#__finder_links_terms7" ( - "link_id" integer NOT NULL, - "term_id" integer NOT NULL, - "weight" numeric(8,2) NOT NULL, - PRIMARY KEY ("link_id", "term_id") -); -CREATE INDEX "#__finder_links_terms7_idx_term_weight" on "#__finder_links_terms7" ("term_id", "weight"); -CREATE INDEX "#__finder_links_terms7_idx_link_term_weight" on "#__finder_links_terms7" ("link_id", "term_id", "weight"); - --- --- Table structure for table `#__finder_links_terms8` --- - -CREATE TABLE IF NOT EXISTS "#__finder_links_terms8" ( - "link_id" integer NOT NULL, - "term_id" integer NOT NULL, - "weight" numeric(8,2) NOT NULL, - PRIMARY KEY ("link_id", "term_id") -); -CREATE INDEX "#__finder_links_terms8_idx_term_weight" on "#__finder_links_terms8" ("term_id", "weight"); -CREATE INDEX "#__finder_links_terms8_idx_link_term_weight" on "#__finder_links_terms8" ("link_id", "term_id", "weight"); - --- --- Table structure for table `#__finder_links_terms9` --- - -CREATE TABLE IF NOT EXISTS "#__finder_links_terms9" ( - "link_id" integer NOT NULL, - "term_id" integer NOT NULL, - "weight" numeric(8,2) NOT NULL, - PRIMARY KEY ("link_id", "term_id") -); -CREATE INDEX "#__finder_links_terms9_idx_term_weight" on "#__finder_links_terms9" ("term_id", "weight"); -CREATE INDEX "#__finder_links_terms9_idx_link_term_weight" on "#__finder_links_terms9" ("link_id", "term_id", "weight"); - --- --- Table structure for table `#__finder_links_termsa` --- - -CREATE TABLE IF NOT EXISTS "#__finder_links_termsa" ( - "link_id" integer NOT NULL, - "term_id" integer NOT NULL, - "weight" numeric(8,2) NOT NULL, - PRIMARY KEY ("link_id", "term_id") -); -CREATE INDEX "#__finder_links_termsa_idx_term_weight" on "#__finder_links_termsa" ("term_id", "weight"); -CREATE INDEX "#__finder_links_termsa_idx_link_term_weight" on "#__finder_links_termsa" ("link_id", "term_id", "weight"); - --- --- Table structure for table `#__finder_links_termsb` --- - -CREATE TABLE IF NOT EXISTS "#__finder_links_termsb" ( - "link_id" integer NOT NULL, - "term_id" integer NOT NULL, - "weight" numeric(8,2) NOT NULL, - PRIMARY KEY ("link_id", "term_id") -); -CREATE INDEX "#__finder_links_termsb_idx_term_weight" on "#__finder_links_termsb" ("term_id", "weight"); -CREATE INDEX "#__finder_links_termsb_idx_link_term_weight" on "#__finder_links_termsb" ("link_id", "term_id", "weight"); - --- --- Table structure for table `#__finder_links_termsc` --- - -CREATE TABLE IF NOT EXISTS "#__finder_links_termsc" ( - "link_id" integer NOT NULL, - "term_id" integer NOT NULL, - "weight" numeric(8,2) NOT NULL, - PRIMARY KEY ("link_id", "term_id") -); -CREATE INDEX "#__finder_links_termsc_idx_term_weight" on "#__finder_links_termsc" ("term_id", "weight"); -CREATE INDEX "#__finder_links_termsc_idx_link_term_weight" on "#__finder_links_termsc" ("link_id", "term_id", "weight"); - --- --- Table structure for table `#__finder_links_termsd` --- - -CREATE TABLE IF NOT EXISTS "#__finder_links_termsd" ( - "link_id" integer NOT NULL, - "term_id" integer NOT NULL, - "weight" numeric(8,2) NOT NULL, - PRIMARY KEY ("link_id", "term_id") -); -CREATE INDEX "#__finder_links_termsd_idx_term_weight" on "#__finder_links_termsd" ("term_id", "weight"); -CREATE INDEX "#__finder_links_termsd_idx_link_term_weight" on "#__finder_links_termsd" ("link_id", "term_id", "weight"); - --- --- Table structure for table `#__finder_links_termse` --- - -CREATE TABLE IF NOT EXISTS "#__finder_links_termse" ( - "link_id" integer NOT NULL, - "term_id" integer NOT NULL, - "weight" numeric(8,2) NOT NULL, - PRIMARY KEY ("link_id", "term_id") -); -CREATE INDEX "#__finder_links_termse_idx_term_weight" on "#__finder_links_termse" ("term_id", "weight"); -CREATE INDEX "#__finder_links_termse_idx_link_term_weight" on "#__finder_links_termse" ("link_id", "term_id", "weight"); - --- --- Table structure for table `#__finder_links_termsf` --- - -CREATE TABLE IF NOT EXISTS "#__finder_links_termsf" ( - "link_id" integer NOT NULL, - "term_id" integer NOT NULL, - "weight" numeric(8,2) NOT NULL, - PRIMARY KEY ("link_id", "term_id") -); -CREATE INDEX "#__finder_links_termsf_idx_term_weight" on "#__finder_links_termsf" ("term_id", "weight"); -CREATE INDEX "#__finder_links_termsf_idx_link_term_weight" on "#__finder_links_termsf" ("link_id", "term_id", "weight"); +CREATE INDEX "#__finder_links_terms_idx_term_weight" on "#__finder_links_terms" ("term_id", "weight"); +CREATE INDEX "#__finder_links_terms_idx_link_term_weight" on "#__finder_links_terms" ("link_id", "term_id", "weight"); -- -- Table structure for table `#__finder_taxonomy` @@ -1072,7 +877,7 @@ CREATE TABLE IF NOT EXISTS "#__finder_terms" ( "weight" numeric(8,2) DEFAULT 0 NOT NULL, "soundex" varchar(75) NOT NULL, "links" integer DEFAULT 0 NOT NULL, - "language" varchar(3) NOT NULL, + "language" varchar(7) NOT NULL, PRIMARY KEY ("term_id"), CONSTRAINT "#__finder_terms_idx_term" UNIQUE ("term") ); @@ -1086,7 +891,7 @@ CREATE INDEX "#__finder_terms_idx_soundex_phrase" on "#__finder_terms" ("soundex CREATE TABLE IF NOT EXISTS "#__finder_terms_common" ( "term" varchar(75) NOT NULL, - "language" varchar(3) DEFAULT '' NOT NULL + "language" varchar(7) DEFAULT '' NOT NULL ); CREATE INDEX "#__finder_terms_common_idx_word_lang" on "#__finder_terms_common" ("term", "language"); CREATE INDEX "#__finder_terms_common_idx_lang" on "#__finder_terms_common" ("language"); @@ -1096,116 +901,116 @@ CREATE INDEX "#__finder_terms_common_idx_lang" on "#__finder_terms_common" ("lan -- INSERT INTO "#__finder_terms_common" ("term", "language") VALUES -('a', 'en'), -('about', 'en'), -('after', 'en'), -('ago', 'en'), -('all', 'en'), -('am', 'en'), -('an', 'en'), -('and', 'en'), -('any', 'en'), -('are', 'en'), -('aren''t', 'en'), -('as', 'en'), -('at', 'en'), -('be', 'en'), -('but', 'en'), -('by', 'en'), -('for', 'en'), -('from', 'en'), -('get', 'en'), -('go', 'en'), -('how', 'en'), -('if', 'en'), -('in', 'en'), -('into', 'en'), -('is', 'en'), -('isn''t', 'en'), -('it', 'en'), -('its', 'en'), -('me', 'en'), -('more', 'en'), -('most', 'en'), -('must', 'en'), -('my', 'en'), -('new', 'en'), -('no', 'en'), -('none', 'en'), -('not', 'en'), -('nothing', 'en'), -('of', 'en'), -('off', 'en'), -('often', 'en'), -('old', 'en'), -('on', 'en'), -('onc', 'en'), -('once', 'en'), -('only', 'en'), -('or', 'en'), -('other', 'en'), -('our', 'en'), -('ours', 'en'), -('out', 'en'), -('over', 'en'), -('page', 'en'), -('she', 'en'), -('should', 'en'), -('small', 'en'), -('so', 'en'), -('some', 'en'), -('than', 'en'), -('thank', 'en'), -('that', 'en'), -('the', 'en'), -('their', 'en'), -('theirs', 'en'), -('them', 'en'), -('then', 'en'), -('there', 'en'), -('these', 'en'), -('they', 'en'), -('this', 'en'), -('those', 'en'), -('thus', 'en'), -('time', 'en'), -('times', 'en'), -('to', 'en'), -('too', 'en'), -('true', 'en'), -('under', 'en'), -('until', 'en'), -('up', 'en'), -('upon', 'en'), -('use', 'en'), -('user', 'en'), -('users', 'en'), -('version', 'en'), -('very', 'en'), -('via', 'en'), -('want', 'en'), -('was', 'en'), -('way', 'en'), -('were', 'en'), -('what', 'en'), -('when', 'en'), -('where', 'en'), -('which', 'en'), -('who', 'en'), -('whom', 'en'), -('whose', 'en'), -('why', 'en'), -('wide', 'en'), -('will', 'en'), -('with', 'en'), -('within', 'en'), -('without', 'en'), -('would', 'en'), -('yes', 'en'), -('yet', 'en'), -('you', 'en'), -('your', 'en'), -('yours', 'en'); +('a', 'en-GB'), +('about', 'en-GB'), +('after', 'en-GB'), +('ago', 'en-GB'), +('all', 'en-GB'), +('am', 'en-GB'), +('an', 'en-GB'), +('and', 'en-GB'), +('any', 'en-GB'), +('are', 'en-GB'), +('aren''t', 'en-GB'), +('as', 'en-GB'), +('at', 'en-GB'), +('be', 'en-GB'), +('but', 'en-GB'), +('by', 'en-GB'), +('for', 'en-GB'), +('from', 'en-GB'), +('get', 'en-GB'), +('go', 'en-GB'), +('how', 'en-GB'), +('if', 'en-GB'), +('in', 'en-GB'), +('into', 'en-GB'), +('is', 'en-GB'), +('isn''t', 'en-GB'), +('it', 'en-GB'), +('its', 'en-GB'), +('me', 'en-GB'), +('more', 'en-GB'), +('most', 'en-GB'), +('must', 'en-GB'), +('my', 'en-GB'), +('new', 'en-GB'), +('no', 'en-GB'), +('none', 'en-GB'), +('not', 'en-GB'), +('nothing', 'en-GB'), +('of', 'en-GB'), +('off', 'en-GB'), +('often', 'en-GB'), +('old', 'en-GB'), +('on', 'en-GB'), +('onc', 'en-GB'), +('once', 'en-GB'), +('only', 'en-GB'), +('or', 'en-GB'), +('other', 'en-GB'), +('our', 'en-GB'), +('ours', 'en-GB'), +('out', 'en-GB'), +('over', 'en-GB'), +('page', 'en-GB'), +('she', 'en-GB'), +('should', 'en-GB'), +('small', 'en-GB'), +('so', 'en-GB'), +('some', 'en-GB'), +('than', 'en-GB'), +('thank', 'en-GB'), +('that', 'en-GB'), +('the', 'en-GB'), +('their', 'en-GB'), +('theirs', 'en-GB'), +('them', 'en-GB'), +('then', 'en-GB'), +('there', 'en-GB'), +('these', 'en-GB'), +('they', 'en-GB'), +('this', 'en-GB'), +('those', 'en-GB'), +('thus', 'en-GB'), +('time', 'en-GB'), +('times', 'en-GB'), +('to', 'en-GB'), +('too', 'en-GB'), +('true', 'en-GB'), +('under', 'en-GB'), +('until', 'en-GB'), +('up', 'en-GB'), +('upon', 'en-GB'), +('use', 'en-GB'), +('user', 'en-GB'), +('users', 'en-GB'), +('version', 'en-GB'), +('very', 'en-GB'), +('via', 'en-GB'), +('want', 'en-GB'), +('was', 'en-GB'), +('way', 'en-GB'), +('were', 'en-GB'), +('what', 'en-GB'), +('when', 'en-GB'), +('where', 'en-GB'), +('which', 'en-GB'), +('who', 'en-GB'), +('whom', 'en-GB'), +('whose', 'en-GB'), +('why', 'en-GB'), +('wide', 'en-GB'), +('will', 'en-GB'), +('with', 'en-GB'), +('within', 'en-GB'), +('without', 'en-GB'), +('would', 'en-GB'), +('yes', 'en-GB'), +('yet', 'en-GB'), +('you', 'en-GB'), +('your', 'en-GB'), +('yours', 'en-GB'); -- -- Table structure for table `#__finder_tokens` @@ -1218,7 +1023,7 @@ CREATE TABLE IF NOT EXISTS "#__finder_tokens" ( "phrase" smallint DEFAULT 0 NOT NULL, "weight" numeric(8,2) DEFAULT 1 NOT NULL, "context" smallint DEFAULT 2 NOT NULL, - "language" varchar(3) NOT NULL + "language" varchar(7) NOT NULL ); CREATE INDEX "#__finder_tokens_idx_word" on "#__finder_tokens" ("term"); CREATE INDEX "#__finder_tokens_idx_context" on "#__finder_tokens" ("context"); @@ -1229,7 +1034,6 @@ CREATE INDEX "#__finder_tokens_idx_context" on "#__finder_tokens" ("context"); CREATE TABLE IF NOT EXISTS "#__finder_tokens_aggregate" ( "term_id" integer NOT NULL, - "map_suffix" varchar(1) NOT NULL, "term" varchar(75) NOT NULL, "stem" varchar(75) NOT NULL, "common" smallint DEFAULT 0 NOT NULL, @@ -1238,7 +1042,7 @@ CREATE TABLE IF NOT EXISTS "#__finder_tokens_aggregate" ( "context" smallint DEFAULT 2 NOT NULL, "context_weight" numeric(8,2) NOT NULL, "total_weight" numeric(8,2) NOT NULL, - "language" varchar(3) NOT NULL + "language" varchar(7) NOT NULL ); CREATE INDEX "#__finder_tokens_aggregate_token" on "#__finder_tokens_aggregate" ("term"); CREATE INDEX "_#__finder_tokens_aggregate_keyword_id" on "#__finder_tokens_aggregate" ("term_id"); @@ -1286,7 +1090,7 @@ CREATE INDEX "#__languages_idx_access" ON "#__languages" ("access"); -- INSERT INTO "#__languages" ("lang_id", "lang_code", "title", "title_native", "sef", "image", "description", "metakey", "metadesc", "sitename", "published", "access", "ordering") VALUES -(1, 'en-GB', 'English (en-GB)', 'English (United Kingdom)', 'en', 'en_gb', '', '', '', '', 1, 1, 1); +(1, 'en-GB', 'English (en-GB)', 'English (United Kingdom)', 'en-GB', 'en_gb', '', '', '', '', 1, 1, 1); SELECT setval('#__languages_lang_id_seq', 2, false);