summaryrefslogtreecommitdiff
path: root/lib/search_engines.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/search_engines.php')
-rw-r--r--lib/search_engines.php33
1 files changed, 22 insertions, 11 deletions
diff --git a/lib/search_engines.php b/lib/search_engines.php
index d53d7d8d8..e96570d63 100644
--- a/lib/search_engines.php
+++ b/lib/search_engines.php
@@ -23,19 +23,23 @@ class SearchEngine {
protected $target;
protected $table;
- function __construct($target, $table) {
+ function __construct($target, $table)
+ {
$this->target = $target;
$this->table = $table;
}
- function query($q) {
+ function query($q)
+ {
}
- function limit($offset, $count, $rss = false) {
+ function limit($offset, $count, $rss = false)
+ {
return $this->target->limit($offset, $count);
}
- function set_sort_mode($mode) {
+ function set_sort_mode($mode)
+ {
if ('chron' === $mode)
return $this->target->orderBy('created desc');
}
@@ -45,7 +49,8 @@ class SphinxSearch extends SearchEngine {
private $sphinx;
private $connected;
- function __construct($target, $table) {
+ function __construct($target, $table)
+ {
$fp = @fsockopen(common_config('sphinx', 'server'), common_config('sphinx', 'port'));
if (!$fp) {
$this->connected = false;
@@ -58,11 +63,13 @@ class SphinxSearch extends SearchEngine {
$this->connected = true;
}
- function is_connected() {
+ function is_connected()
+ {
return $this->connected;
}
- function limit($offset, $count, $rss = false) {
+ function limit($offset, $count, $rss = false)
+ {
//FIXME without LARGEST_POSSIBLE, the most recent results aren't returned
// this probably has a large impact on performance
$LARGEST_POSSIBLE = 1e6;
@@ -78,7 +85,8 @@ class SphinxSearch extends SearchEngine {
return $this->target->limit(0, $count);
}
- function query($q) {
+ function query($q)
+ {
$result = $this->sphinx->query($q, $this->table);
if (!isset($result['matches'])) return false;
$id_set = join(', ', array_keys($result['matches']));
@@ -86,7 +94,8 @@ class SphinxSearch extends SearchEngine {
return true;
}
- function set_sort_mode($mode) {
+ function set_sort_mode($mode)
+ {
if ('chron' === $mode) {
$this->sphinx->SetSortMode(SPH_SORT_ATTR_DESC, 'created_ts');
return $this->target->orderBy('created desc');
@@ -95,7 +104,8 @@ class SphinxSearch extends SearchEngine {
}
class MySQLSearch extends SearchEngine {
- function query($q) {
+ function query($q)
+ {
if ('identica_people' === $this->table)
return $this->target->whereAdd('MATCH(nickname, fullname, location, bio, homepage) ' .
'against (\''.addslashes($q).'\')');
@@ -106,7 +116,8 @@ class MySQLSearch extends SearchEngine {
}
class PGSearch extends SearchEngine {
- function query($q) {
+ function query($q)
+ {
if ('identica_people' === $this->table)
return $this->target->whereAdd('textsearch @@ plainto_tsquery(\''.addslashes($q).'\')');
if ('identica_notices' === $this->table)