diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2014-03-14 10:13:42 +0100 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2014-03-14 10:13:42 +0100 |
commit | 5f8f1f04fdcc30b0d2c3173661eb8eefbc371a4d (patch) | |
tree | 3c9fe1936aa216b0fe9d22299963aa9c7e116b5d /phpBB/phpbb/search/fulltext_postgres.php | |
parent | 3c6a17ae6bc494d68f7230c932e9ac036207ce77 (diff) | |
parent | 6918921d53da75bf1b77dcbffff10e8dc574fbdb (diff) | |
download | forums-5f8f1f04fdcc30b0d2c3173661eb8eefbc371a4d.tar forums-5f8f1f04fdcc30b0d2c3173661eb8eefbc371a4d.tar.gz forums-5f8f1f04fdcc30b0d2c3173661eb8eefbc371a4d.tar.bz2 forums-5f8f1f04fdcc30b0d2c3173661eb8eefbc371a4d.tar.xz forums-5f8f1f04fdcc30b0d2c3173661eb8eefbc371a4d.zip |
Merge remote-tracking branch 'dhruv/ticket/11040' into develop
* dhruv/ticket/11040:
[ticket/11040] Topic is deleted if test is skipped
[ticket/11040] Use unique text for the test post added
[ticket/11040] Use hard delete in delete_topic
[ticket/11040] Add migration to drop postgres search indexes
[ticket/11040] Delete the functional test topic to avoid conflicts
[ticket/11040] Add methods to delete post and topic in functional tests
[ticket/11040] Swap post_text and post_subject for post_content index
[ticket/11040] Add test cases for searching subject and post content together
[ticket/11040] Remove postgres extra indexes
[ticket/11040] Add post_content index
[ticket/11040] Search subject and text together
Diffstat (limited to 'phpBB/phpbb/search/fulltext_postgres.php')
-rw-r--r-- | phpBB/phpbb/search/fulltext_postgres.php | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/phpBB/phpbb/search/fulltext_postgres.php b/phpBB/phpbb/search/fulltext_postgres.php index 063bf52a19..63caeffcc5 100644 --- a/phpBB/phpbb/search/fulltext_postgres.php +++ b/phpBB/phpbb/search/fulltext_postgres.php @@ -457,15 +457,13 @@ class fulltext_postgres extends \phpbb\search\base $sql_where_options .= $sql_match_where; $tmp_sql_match = array(); - foreach (explode(',', $sql_match) as $sql_match_column) - { - $tmp_sql_match[] = "to_tsvector ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', " . $sql_match_column . ") @@ to_tsquery ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', '" . $this->db->sql_escape($this->tsearch_query) . "')"; - } + $sql_match = str_replace(',', " || ' ' ||", $sql_match); + $tmp_sql_match = "to_tsvector ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', " . $sql_match . ") @@ to_tsquery ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', '" . $this->db->sql_escape($this->tsearch_query) . "')"; $this->db->sql_transaction('begin'); $sql_from = "FROM $sql_from$sql_sort_table" . POSTS_TABLE . " p"; - $sql_where = "WHERE (" . implode(' OR ', $tmp_sql_match) . ") + $sql_where = "WHERE (" . $tmp_sql_match . ") $sql_where_options"; $sql = "SELECT $sql_select $sql_from @@ -793,9 +791,9 @@ class fulltext_postgres extends \phpbb\search\base $this->db->sql_query("CREATE INDEX " . POSTS_TABLE . "_" . $this->config['fulltext_postgres_ts_name'] . "_post_subject ON " . POSTS_TABLE . " USING gin (to_tsvector ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', post_subject))"); } - if (!isset($this->stats['post_text'])) + if (!isset($this->stats['post_content'])) { - $this->db->sql_query("CREATE INDEX " . POSTS_TABLE . "_" . $this->config['fulltext_postgres_ts_name'] . "_post_text ON " . POSTS_TABLE . " USING gin (to_tsvector ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', post_text))"); + $this->db->sql_query("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))"); } $this->db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE); @@ -826,9 +824,9 @@ class fulltext_postgres extends \phpbb\search\base $this->db->sql_query('DROP INDEX ' . $this->stats['post_subject']['relname']); } - if (isset($this->stats['post_text'])) + if (isset($this->stats['post_content'])) { - $this->db->sql_query('DROP INDEX ' . $this->stats['post_text']['relname']); + $this->db->sql_query('DROP INDEX ' . $this->stats['post_content']['relname']); } $this->db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE); @@ -846,7 +844,7 @@ class fulltext_postgres extends \phpbb\search\base $this->get_stats(); } - return (isset($this->stats['post_text']) && isset($this->stats['post_subject'])) ? true : false; + return (isset($this->stats['post_subject']) && isset($this->stats['post_content'])) ? true : false; } /** @@ -888,13 +886,13 @@ class fulltext_postgres extends \phpbb\search\base // deal with older PostgreSQL versions which didn't use Index_type if (strpos($row['indexdef'], 'to_tsvector') !== false) { - if ($row['relname'] == POSTS_TABLE . '_' . $this->config['fulltext_postgres_ts_name'] . '_post_text' || $row['relname'] == POSTS_TABLE . '_post_text') + if ($row['relname'] == POSTS_TABLE . '_' . $this->config['fulltext_postgres_ts_name'] . '_post_subject' || $row['relname'] == POSTS_TABLE . '_post_subject') { - $this->stats['post_text'] = $row; + $this->stats['post_subject'] = $row; } - else if ($row['relname'] == POSTS_TABLE . '_' . $this->config['fulltext_postgres_ts_name'] . '_post_subject' || $row['relname'] == POSTS_TABLE . '_post_subject') + else if ($row['relname'] == POSTS_TABLE . '_' . $this->config['fulltext_postgres_ts_name'] . '_post_content' || $row['relname'] == POSTS_TABLE . '_post_content') { - $this->stats['post_subject'] = $row; + $this->stats['post_content'] = $row; } } } |