aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDhruv <dhruv.goel92@gmail.com>2012-08-12 01:40:30 +0530
committerDhruv <dhruv.goel92@gmail.com>2014-03-12 11:01:42 +0530
commit87688687e4eaa274ccfec10c43b6b91d050d05e5 (patch)
tree1c87a56c866eb481beec8d52b84350857d604f16
parent274c83c74d128fc2e5a63c7c178250c862f90182 (diff)
downloadforums-87688687e4eaa274ccfec10c43b6b91d050d05e5.tar
forums-87688687e4eaa274ccfec10c43b6b91d050d05e5.tar.gz
forums-87688687e4eaa274ccfec10c43b6b91d050d05e5.tar.bz2
forums-87688687e4eaa274ccfec10c43b6b91d050d05e5.tar.xz
forums-87688687e4eaa274ccfec10c43b6b91d050d05e5.zip
[ticket/11040] Add post_content index
In addition to post_subject and post_title indexes add a post_content which is concatenation of both the columns. PHPBB3-11040
-rw-r--r--phpBB/phpbb/search/fulltext_postgres.php16
1 files changed, 15 insertions, 1 deletions
diff --git a/phpBB/phpbb/search/fulltext_postgres.php b/phpBB/phpbb/search/fulltext_postgres.php
index 7df61ee583..32519b1f14 100644
--- a/phpBB/phpbb/search/fulltext_postgres.php
+++ b/phpBB/phpbb/search/fulltext_postgres.php
@@ -796,6 +796,11 @@ class fulltext_postgres extends \phpbb\search\base
$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))");
}
+ if (!isset($this->stats['post_content']))
+ {
+ $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_subject || ' ' || post_text))");
+ }
+
$this->db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE);
return false;
@@ -829,6 +834,11 @@ class fulltext_postgres extends \phpbb\search\base
$this->db->sql_query('DROP INDEX ' . $this->stats['post_text']['relname']);
}
+ if (isset($this->stats['post_content']))
+ {
+ $this->db->sql_query('DROP INDEX ' . $this->stats['post_content']['relname']);
+ }
+
$this->db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE);
return false;
@@ -844,7 +854,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_text']) && isset($this->stats['post_subject']) && isset($this->stats['post_content'])) ? true : false;
}
/**
@@ -894,6 +904,10 @@ class fulltext_postgres extends \phpbb\search\base
{
$this->stats['post_subject'] = $row;
}
+ else if ($row['relname'] == POSTS_TABLE . '_' . $this->config['fulltext_postgres_ts_name'] . '_post_content' || $row['relname'] == POSTS_TABLE . '_post_content')
+ {
+ $this->stats['post_content'] = $row;
+ }
}
}
$this->db->sql_freeresult($result);