aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/search/fulltext_postgres.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/search/fulltext_postgres.php')
-rw-r--r--phpBB/includes/search/fulltext_postgres.php82
1 files changed, 75 insertions, 7 deletions
diff --git a/phpBB/includes/search/fulltext_postgres.php b/phpBB/includes/search/fulltext_postgres.php
index 38989a9d9a..08f64735b6 100644
--- a/phpBB/includes/search/fulltext_postgres.php
+++ b/phpBB/includes/search/fulltext_postgres.php
@@ -22,22 +22,84 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_search_fulltext_postgres extends phpbb_search_base
{
+ /**
+ * Associative array holding index stats
+ * @var array
+ */
protected $stats = array();
+
+ /**
+ * Holds the words entered by user, obtained by splitting the entered query on whitespace
+ * @var array
+ */
protected $split_words = array();
+
+ /**
+ * True if PostgreSQL version supports tsearch
+ * @var boolean
+ */
protected $tsearch_usable = false;
+
+ /**
+ * Stores the PostgreSQL version
+ * @var string
+ */
protected $version;
+
+ /**
+ * Stores the tsearch query
+ * @var string
+ */
protected $tsearch_query;
+
+ /**
+ * True if phrase search is supported.
+ * PostgreSQL fulltext currently doesn't support it
+ * @var boolean
+ */
protected $phrase_search = false;
+
+ /**
+ * Config object
+ * @var phpbb_config
+ */
protected $config;
+
+ /**
+ * DBAL object
+ * @var dbal
+ */
protected $db;
+
+ /**
+ * User object
+ * @var phpbb_user
+ */
protected $user;
+
+ /**
+ * Contains tidied search query.
+ * Operators are prefixed in search query and common words excluded
+ * @var string
+ */
protected $search_query;
+
+ /**
+ * Contains common words.
+ * Common words are words with length less/more than min/max length
+ * @var array
+ */
protected $common_words = array();
+
+ /**
+ * Associative array stores the min and max word length to be searched
+ * @var array
+ */
protected $word_length = array();
/**
* Constructor
- * Creates a new phpbb_search_fulltext_postgres, which is used as a search backend.
+ * Creates a new phpbb_search_fulltext_postgres, which is used as a search backend
*
* @param string|bool $error Any error that occurs is passed on through this reference variable otherwise false
*/
@@ -254,7 +316,7 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
}
/**
- * Performs a search on keywords depending on display specific params. You have to run split_keywords() first.
+ * Performs a search on keywords depending on display specific params. You have to run split_keywords() first
*
* @param string $type contains either posts or topics depending on what should be searched for
* @param string $fields contains either titleonly (topic titles should be searched), msgonly (only message bodies should be searched), firstpost (only subject and body of the first post should be searched) or all (all post bodies and subjects should be searched)
@@ -275,12 +337,18 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
*/
public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page)
{
- // No keywords? No posts.
+ // No keywords? No posts
if (!$this->search_query)
{
return false;
}
+ // When search query contains queries like -foo
+ if (strpos($this->search_query, '+') === false)
+ {
+ return false;
+ }
+
// generate a search_key from all the options to identify the results
$search_key = md5(implode('#', array(
implode(', ', $this->split_words),
@@ -459,7 +527,7 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
*/
public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page)
{
- // No author? No posts.
+ // No author? No posts
if (!sizeof($author_ary))
{
return 0;
@@ -602,7 +670,7 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
}
/**
- * Destroys cached search results, that contained one of the new words in a post so the results won't be outdated.
+ * Destroys cached search results, that contained one of the new words in a post so the results won't be outdated
*
* @param string $mode contains the post mode: edit, post, reply, quote ...
* @param int $post_id contains the post id of the post to index
@@ -816,11 +884,11 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
$tpl .= '</select></dd>
</dl>
<dl>
- <dt><label for="fulltext_postgres_min_word_len">' . $this->user->lang['FULLTEXT_POSTGRES_MIN_WORD_LEN'] . ':</label><br /><span>' . $this->user->lang['FULLTEXT_POSTGRES_MIN_WORD_LEN_EXPLAIN'] . '</span></dt>
+ <dt><label for="fulltext_postgres_min_word_len">' . $this->user->lang['FULLTEXT_POSTGRES_MIN_WORD_LEN'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['FULLTEXT_POSTGRES_MIN_WORD_LEN_EXPLAIN'] . '</span></dt>
<dd><input id="fulltext_postgres_min_word_len" type="text" size="3" maxlength="3" name="config[fulltext_postgres_min_word_len]" value="' . (int) $this->config['fulltext_postgres_min_word_len'] . '" /></dd>
</dl>
<dl>
- <dt><label for="fulltext_postgres_max_word_len">' . $this->user->lang['FULLTEXT_POSTGRES_MAX_WORD_LEN'] . ':</label><br /><span>' . $this->user->lang['FULLTEXT_POSTGRES_MAX_WORD_LEN_EXPLAIN'] . '</span></dt>
+ <dt><label for="fulltext_postgres_max_word_len">' . $this->user->lang['FULLTEXT_POSTGRES_MAX_WORD_LEN'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['FULLTEXT_POSTGRES_MAX_WORD_LEN_EXPLAIN'] . '</span></dt>
<dd><input id="fulltext_postgres_max_word_len" type="text" size="3" maxlength="3" name="config[fulltext_postgres_max_word_len]" value="' . (int) $this->config['fulltext_postgres_max_word_len'] . '" /></dd>
</dl>
';