Add like for search
This commit is contained in:
parent
02a4ca9e2e
commit
876ab05927
13
README
13
README
@ -1247,7 +1247,6 @@ Options for group functionality.
|
|||||||
maxaliases: maximum number of aliases a group can have. Default 3. Set
|
maxaliases: maximum number of aliases a group can have. Default 3. Set
|
||||||
to 0 or less to prevent aliases in a group.
|
to 0 or less to prevent aliases in a group.
|
||||||
|
|
||||||
|
|
||||||
oohembed
|
oohembed
|
||||||
--------
|
--------
|
||||||
|
|
||||||
@ -1255,6 +1254,18 @@ oEmbed endpoint for multimedia attachments (links in posts).
|
|||||||
|
|
||||||
endpoint: oohembed endpoint using http://oohembed.com/ software.
|
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
|
Troubleshooting
|
||||||
===============
|
===============
|
||||||
|
|
||||||
|
@ -193,7 +193,14 @@ class Memcached_DataObject extends DB_DataObject
|
|||||||
// unable to connect to sphinx' search daemon
|
// unable to connect to sphinx' search daemon
|
||||||
if (!$connected) {
|
if (!$connected) {
|
||||||
if ('mysql' === common_config('db', 'type')) {
|
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 {
|
} else {
|
||||||
$search_engine = new PGSearch($this, $table);
|
$search_engine = new PGSearch($this, $table);
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,9 @@ $config =
|
|||||||
),
|
),
|
||||||
'group' =>
|
'group' =>
|
||||||
array('maxaliases' => 3),
|
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');
|
$config['db'] = &PEAR::getStaticProperty('DB_DataObject','options');
|
||||||
|
@ -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
|
class PGSearch extends SearchEngine
|
||||||
{
|
{
|
||||||
function query($q)
|
function query($q)
|
||||||
|
Loading…
Reference in New Issue
Block a user