From a29d2e1149b45cd341b49d196ddc8fff7bacd814 Mon Sep 17 00:00:00 2001 From: Kidounet Date: Sun, 26 Jan 2020 13:11:55 +0100 Subject: [PATCH] [ticket/15395] change GIN tsvector indexes in Postgres Fulltext Search PHPBB3-15395 --- phpBB/phpbb/search/fulltext_postgres.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/phpBB/phpbb/search/fulltext_postgres.php b/phpBB/phpbb/search/fulltext_postgres.php index 2f387e791e..2b1631dae7 100644 --- a/phpBB/phpbb/search/fulltext_postgres.php +++ b/phpBB/phpbb/search/fulltext_postgres.php @@ -972,7 +972,12 @@ class fulltext_postgres extends \phpbb\search\base if (!isset($this->stats['post_content'])) { - $sql_queries[] = "CREATE INDEX " . POSTS_TABLE . "_" . $this->config['fulltext_postgres_ts_name'] . "_post_content ON " . POSTS_TABLE . " USING gin (to_tsvector ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', post_text || ' ' || post_subject))"; + $sql_queries[] = "CREATE INDEX " . POSTS_TABLE . "_" . $this->config['fulltext_postgres_ts_name'] . "_post_content ON " . POSTS_TABLE . " USING gin (to_tsvector ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', post_text))"; + } + + if (!isset($this->stats['post_subject_content'])) + { + $sql_queries[] = "CREATE INDEX " . POSTS_TABLE . "_" . $this->config['fulltext_postgres_ts_name'] . "_post_subject_content ON " . POSTS_TABLE . " USING gin (to_tsvector ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', post_subject || ' ' || post_text))"; } $stats = $this->stats; @@ -1031,6 +1036,11 @@ class fulltext_postgres extends \phpbb\search\base $sql_queries[] = 'DROP INDEX ' . $this->stats['post_content']['relname']; } + if (isset($this->stats['post_subject_content'])) + { + $sql_queries[] = 'DROP INDEX ' . $this->stats['post_subject_content']['relname']; + } + $stats = $this->stats; /** @@ -1117,6 +1127,10 @@ class fulltext_postgres extends \phpbb\search\base { $this->stats['post_content'] = $row; } + else if ($row['relname'] == POSTS_TABLE . '_' . $this->config['fulltext_postgres_ts_name'] . '_post_subject_content' || $row['relname'] == POSTS_TABLE . '_post_subject_content') + { + $this->stats['post_subject_content'] = $row; + } } } $this->db->sql_freeresult($result);