summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlyourself.ca>2009-03-19 11:03:07 -0400
committerEvan Prodromou <evan@controlyourself.ca>2009-03-19 11:03:07 -0400
commit739bb522fd5d3ec57d6b7a7398c33f96d65a8d4e (patch)
tree6a20993fbdbbf9467d36a2a5d87de73a807435c2 /lib
parente7c57b43073888d18760e2411b207a4ee2cf508b (diff)
parentd1b2a9d7087ecc171f941755b4c3a420cd202842 (diff)
Merge branch 'master' into 0.7.x
Diffstat (limited to 'lib')
-rw-r--r--lib/search_engines.php34
1 files changed, 25 insertions, 9 deletions
diff --git a/lib/search_engines.php b/lib/search_engines.php
index 559107910..7b9dbb618 100644
--- a/lib/search_engines.php
+++ b/lib/search_engines.php
@@ -74,7 +74,7 @@ class SphinxSearch extends SearchEngine
{
//FIXME without LARGEST_POSSIBLE, the most recent results aren't returned
// this probably has a large impact on performance
- $LARGEST_POSSIBLE = 1e6;
+ $LARGEST_POSSIBLE = 1e6;
if ($rss) {
$this->sphinx->setLimits($offset, $count, $count, $LARGEST_POSSIBLE);
@@ -109,12 +109,25 @@ class MySQLSearch extends SearchEngine
{
function query($q)
{
- if ('identica_people' === $this->table)
- return $this->target->whereAdd('MATCH(nickname, fullname, location, bio, homepage) ' .
- 'against (\''.addslashes($q).'\')');
- if ('identica_notices' === $this->table)
- return $this->target->whereAdd('MATCH(content) ' .
- 'against (\''.addslashes($q).'\')');
+ if ('identica_people' === $this->table) {
+ $this->target->whereAdd('MATCH(nickname, fullname, location, bio, homepage) ' .
+ 'AGAINST (\''.addslashes($q).'\' IN BOOLEAN MODE)');
+ if (strtolower($q) != $q) {
+ $this->target->whereAdd('MATCH(nickname, fullname, location, bio, homepage) ' .
+ 'AGAINST (\''.addslashes(strtolower($q)).'\' IN BOOLEAN MODE)', 'OR');
+ }
+ return true;
+ } else if ('identica_notices' === $this->table) {
+ $this->target->whereAdd('MATCH(content) ' .
+ 'AGAINST (\''.addslashes($q).'\' IN BOOLEAN MODE)');
+ if (strtolower($q) != $q) {
+ $this->target->whereAdd('MATCH(content) ' .
+ 'AGAINST (\''.addslashes(strtolower($q)).'\' IN BOOLEAN MODE)', 'OR');
+ }
+ return true;
+ } else {
+ throw new ServerException('Unknown table: ' . $this->table);
+ }
}
}
@@ -122,10 +135,13 @@ class PGSearch extends SearchEngine
{
function query($q)
{
- if ('identica_people' === $this->table)
+ if ('identica_people' === $this->table) {
return $this->target->whereAdd('textsearch @@ plainto_tsquery(\''.addslashes($q).'\')');
- if ('identica_notices' === $this->table)
+ } else if ('identica_notices' === $this->table) {
return $this->target->whereAdd('to_tsvector(\'english\', content) @@ plainto_tsquery(\''.addslashes($q).'\')');
+ } else {
+ throw new ServerException('Unknown table: ' . $this->table);
+ }
}
}