summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README13
-rw-r--r--classes/Memcached_DataObject.php9
-rw-r--r--lib/common.php4
-rw-r--r--lib/search_engines.php22
4 files changed, 45 insertions, 3 deletions
diff --git a/README b/README
index 5aa7270ee..0c500acb8 100644
--- a/README
+++ b/README
@@ -1247,7 +1247,6 @@ Options for group functionality.
maxaliases: maximum number of aliases a group can have. Default 3. Set
to 0 or less to prevent aliases in a group.
-
oohembed
--------
@@ -1255,6 +1254,18 @@ oEmbed endpoint for multimedia attachments (links in posts).
endpoint: oohembed endpoint using http://oohembed.com/ software.
+search
+------
+
+Some stuff for search.
+
+type: type of search. Ignored if PostgreSQL or Sphinx are enabled. Can either
+ be 'fulltext' (default) or 'like'. The former is faster and more efficient
+ but requires the lame old MyISAM engine for MySQL. The latter
+ will work with InnoDB but could be miserably slow on large
+ systems. We'll probably add another type sometime in the future,
+ with our own indexing system (maybe like MediaWiki's).
+
Troubleshooting
===============
diff --git a/classes/Memcached_DataObject.php b/classes/Memcached_DataObject.php
index 2d5a73554..f7cbb9d5b 100644
--- a/classes/Memcached_DataObject.php
+++ b/classes/Memcached_DataObject.php
@@ -193,7 +193,14 @@ class Memcached_DataObject extends DB_DataObject
// unable to connect to sphinx' search daemon
if (!$connected) {
if ('mysql' === common_config('db', 'type')) {
- $search_engine = new MySQLSearch($this, $table);
+ $type = common_config('search', 'type');
+ if ($type == 'like') {
+ $search_engine = new MySQLLikeSearch($this, $table);
+ } else if ($type == 'fulltext') {
+ $search_engine = new MySQLSearch($this, $table);
+ } else {
+ throw new ServerException('Unknown search type: ' . $type);
+ }
} else {
$search_engine = new PGSearch($this, $table);
}
diff --git a/lib/common.php b/lib/common.php
index 361759d0a..14f5c7a7f 100644
--- a/lib/common.php
+++ b/lib/common.php
@@ -228,7 +228,9 @@ $config =
),
'group' =>
array('maxaliases' => 3),
- 'oohembed' => array('endpoint' => 'http://oohembed.com/oohembed/')
+ 'oohembed' => array('endpoint' => 'http://oohembed.com/oohembed/'),
+ 'search' =>
+ array('type' => 'fulltext'),
);
$config['db'] = &PEAR::getStaticProperty('DB_DataObject','options');
diff --git a/lib/search_engines.php b/lib/search_engines.php
index c98e8ed87..5c84d7c6b 100644
--- a/lib/search_engines.php
+++ b/lib/search_engines.php
@@ -131,6 +131,28 @@ class MySQLSearch extends SearchEngine
}
}
+class MySQLLikeSearch extends SearchEngine
+{
+ function query($q)
+ {
+ if ('identica_people' === $this->table) {
+ $qry = sprintf('(nickname LIKE "%%%1$s%%" OR '.
+ ' fullname LIKE "%%%1$s%%" OR '.
+ ' location LIKE "%%%1$s%%" OR '.
+ ' bio LIKE "%%%1$s%%" OR '.
+ ' homepage LIKE "%%%1$s%%")', addslashes($q));
+ } else if ('identica_notices' === $this->table) {
+ $qry = sprintf('content LIKE "%%%1$s%%"', addslashes($q));
+ } else {
+ throw new ServerException('Unknown table: ' . $this->table);
+ }
+
+ $this->target->whereAdd($qry);
+
+ return true;
+ }
+}
+
class PGSearch extends SearchEngine
{
function query($q)