forked from GNUsocial/gnu-social
Somewhat better behaviour with mixed caps in search
Deal somewhat better with mixed caps in people and notice search.
This commit is contained in:
parent
5dc913f589
commit
d1b2a9d708
@ -1,9 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
// define('GROUPS_PER_PAGE', 20);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Group search action class.
|
* Group search action class.
|
||||||
*
|
*
|
||||||
|
@ -103,7 +103,7 @@ class NoticesearchAction extends SearchAction
|
|||||||
function showResults($q, $page)
|
function showResults($q, $page)
|
||||||
{
|
{
|
||||||
$notice = new Notice();
|
$notice = new Notice();
|
||||||
$q = strtolower($q);
|
|
||||||
$search_engine = $notice->getSearchEngine('identica_notices');
|
$search_engine = $notice->getSearchEngine('identica_notices');
|
||||||
$search_engine->set_sort_mode('chron');
|
$search_engine->set_sort_mode('chron');
|
||||||
// Ask for an extra to see if there's more.
|
// Ask for an extra to see if there's more.
|
||||||
|
@ -62,9 +62,6 @@ class NoticesearchrssAction extends Rss10Action
|
|||||||
|
|
||||||
$notice = new Notice();
|
$notice = new Notice();
|
||||||
|
|
||||||
# lcase it for comparison
|
|
||||||
$q = strtolower($q);
|
|
||||||
|
|
||||||
$search_engine = $notice->getSearchEngine('identica_notices');
|
$search_engine = $notice->getSearchEngine('identica_notices');
|
||||||
$search_engine->set_sort_mode('chron');
|
$search_engine->set_sort_mode('chron');
|
||||||
|
|
||||||
|
@ -63,13 +63,13 @@ class PeoplesearchAction extends SearchAction
|
|||||||
|
|
||||||
$profile = new Profile();
|
$profile = new Profile();
|
||||||
|
|
||||||
# lcase it for comparison
|
// lcase it for comparison
|
||||||
$q = strtolower($q);
|
// $q = strtolower($q);
|
||||||
|
|
||||||
$search_engine = $profile->getSearchEngine('identica_people');
|
$search_engine = $profile->getSearchEngine('identica_people');
|
||||||
|
|
||||||
$search_engine->set_sort_mode('chron');
|
$search_engine->set_sort_mode('chron');
|
||||||
# Ask for an extra to see if there's more.
|
// Ask for an extra to see if there's more.
|
||||||
$search_engine->limit((($page-1)*PROFILES_PER_PAGE), PROFILES_PER_PAGE + 1);
|
$search_engine->limit((($page-1)*PROFILES_PER_PAGE), PROFILES_PER_PAGE + 1);
|
||||||
if (false === $search_engine->query($q)) {
|
if (false === $search_engine->query($q)) {
|
||||||
$cnt = 0;
|
$cnt = 0;
|
||||||
|
@ -109,12 +109,25 @@ class MySQLSearch extends SearchEngine
|
|||||||
{
|
{
|
||||||
function query($q)
|
function query($q)
|
||||||
{
|
{
|
||||||
if ('identica_people' === $this->table)
|
if ('identica_people' === $this->table) {
|
||||||
return $this->target->whereAdd('MATCH(nickname, fullname, location, bio, homepage) ' .
|
$this->target->whereAdd('MATCH(nickname, fullname, location, bio, homepage) ' .
|
||||||
'against (\''.addslashes($q).'\')');
|
'AGAINST (\''.addslashes($q).'\' IN BOOLEAN MODE)');
|
||||||
if ('identica_notices' === $this->table)
|
if (strtolower($q) != $q) {
|
||||||
return $this->target->whereAdd('MATCH(content) ' .
|
$this->target->whereAdd('MATCH(nickname, fullname, location, bio, homepage) ' .
|
||||||
'against (\''.addslashes($q).'\')');
|
'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)
|
function query($q)
|
||||||
{
|
{
|
||||||
if ('identica_people' === $this->table)
|
if ('identica_people' === $this->table) {
|
||||||
return $this->target->whereAdd('textsearch @@ plainto_tsquery(\''.addslashes($q).'\')');
|
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).'\')');
|
return $this->target->whereAdd('to_tsvector(\'english\', content) @@ plainto_tsquery(\''.addslashes($q).'\')');
|
||||||
|
} else {
|
||||||
|
throw new ServerException('Unknown table: ' . $this->table);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user