Speeding up the search for tags.
This commit is contained in:
parent
680524f446
commit
1b0b686116
|
@ -174,8 +174,6 @@ function network_init(&$a) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// search terms header
|
// search terms header
|
||||||
if(x($_GET,'search')) {
|
if(x($_GET,'search')) {
|
||||||
$a->page['content'] .= '<h2>' . t('Search Results For:') . ' ' . $search . '</h2>';
|
$a->page['content'] .= '<h2>' . t('Search Results For:') . ' ' . $search . '</h2>';
|
||||||
|
@ -571,7 +569,6 @@ function network_content(&$a, $update = 0) {
|
||||||
// that belongs to you, hence you can see all of it. We will filter by group if
|
// that belongs to you, hence you can see all of it. We will filter by group if
|
||||||
// desired.
|
// desired.
|
||||||
|
|
||||||
|
|
||||||
$sql_options = (($star) ? " and starred = 1 " : '');
|
$sql_options = (($star) ? " and starred = 1 " : '');
|
||||||
$sql_options .= (($bmark) ? " and bookmark = 1 " : '');
|
$sql_options .= (($bmark) ? " and bookmark = 1 " : '');
|
||||||
|
|
||||||
|
@ -641,6 +638,7 @@ function network_content(&$a, $update = 0) {
|
||||||
|
|
||||||
$sql_extra2 = (($nouveau) ? '' : " AND `item`.`parent` = `item`.`id` ");
|
$sql_extra2 = (($nouveau) ? '' : " AND `item`.`parent` = `item`.`id` ");
|
||||||
$sql_extra3 = (($nouveau) ? '' : $sql_extra3);
|
$sql_extra3 = (($nouveau) ? '' : $sql_extra3);
|
||||||
|
$sql_order = "`item`.`received`";
|
||||||
$sql_table = "`item`";
|
$sql_table = "`item`";
|
||||||
|
|
||||||
if(x($_GET,'search')) {
|
if(x($_GET,'search')) {
|
||||||
|
@ -675,11 +673,15 @@ function network_content(&$a, $update = 0) {
|
||||||
$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d ",
|
$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d ",
|
||||||
dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG));
|
dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG));
|
||||||
$sql_table = "`term` LEFT JOIN `item` ON `item`.`id` = `term`.`oid` AND `item`.`uid` = `term`.`uid` ";
|
$sql_table = "`term` LEFT JOIN `item` ON `item`.`id` = `term`.`oid` AND `item`.`uid` = `term`.`uid` ";
|
||||||
|
|
||||||
|
$sql_order = "`term`.`tid`";
|
||||||
} else {
|
} else {
|
||||||
if (get_config('system','use_fulltext_engine'))
|
if (get_config('system','use_fulltext_engine'))
|
||||||
$sql_extra = sprintf(" AND MATCH (`item`.`body`, `item`.`title`) AGAINST ('%s' in boolean mode) ", dbesc(protect_sprintf($search)));
|
$sql_extra = sprintf(" AND MATCH (`item`.`body`, `item`.`title`) AGAINST ('%s' in boolean mode) ", dbesc(protect_sprintf($search)));
|
||||||
else
|
else
|
||||||
$sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search))));
|
$sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search))));
|
||||||
|
|
||||||
|
$sql_order = "`item`.`received`";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(strlen($file)) {
|
if(strlen($file)) {
|
||||||
|
@ -767,7 +769,7 @@ function network_content(&$a, $update = 0) {
|
||||||
$simple_update
|
$simple_update
|
||||||
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||||
$sql_extra $sql_nets
|
$sql_extra $sql_nets
|
||||||
ORDER BY `item`.`received` DESC $pager_sql ",
|
ORDER BY $sql_order DESC $pager_sql ",
|
||||||
intval($_SESSION['uid'])
|
intval($_SESSION['uid'])
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -783,6 +785,9 @@ function network_content(&$a, $update = 0) {
|
||||||
else
|
else
|
||||||
$ordering = "`commented`";
|
$ordering = "`commented`";
|
||||||
|
|
||||||
|
if ($sql_order == "")
|
||||||
|
$sql_order = "`item`.$ordering";
|
||||||
|
|
||||||
// Fetch a page full of parent items for this page
|
// Fetch a page full of parent items for this page
|
||||||
|
|
||||||
if($update) {
|
if($update) {
|
||||||
|
@ -803,7 +808,7 @@ function network_content(&$a, $update = 0) {
|
||||||
AND `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
AND `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||||
AND `item`.`parent` = `item`.`id`
|
AND `item`.`parent` = `item`.`id`
|
||||||
$sql_extra3 $sql_extra $sql_nets
|
$sql_extra3 $sql_extra $sql_nets
|
||||||
ORDER BY `item`.$ordering DESC $pager_sql ",
|
ORDER BY $sql_order DESC $pager_sql ",
|
||||||
intval(local_user())
|
intval(local_user())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,6 +144,8 @@ function search_content(&$a) {
|
||||||
$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d group by `item`.`uri` ",
|
$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d group by `item`.`uri` ",
|
||||||
dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG));
|
dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG));
|
||||||
$sql_table = "`term` LEFT JOIN `item` ON `item`.`id` = `term`.`oid` AND `item`.`uid` = `term`.`uid` ";
|
$sql_table = "`term` LEFT JOIN `item` ON `item`.`id` = `term`.`oid` AND `item`.`uid` = `term`.`uid` ";
|
||||||
|
$sql_order = "`term`.`tid`";
|
||||||
|
//$sql_order = "`item`.`received`";
|
||||||
|
|
||||||
//$sql_extra = sprintf(" AND EXISTS (SELECT * FROM `term` WHERE `item`.`id` = `term`.`oid` AND `item`.`uid` = `term`.`uid` AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d) GROUP BY `item`.`uri` ",
|
//$sql_extra = sprintf(" AND EXISTS (SELECT * FROM `term` WHERE `item`.`id` = `term`.`oid` AND `item`.`uid` = `term`.`uid` AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d) GROUP BY `item`.`uri` ",
|
||||||
// dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG));
|
// dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG));
|
||||||
|
@ -155,6 +157,7 @@ function search_content(&$a) {
|
||||||
$sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search))));
|
$sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search))));
|
||||||
}
|
}
|
||||||
$sql_table = "`item`";
|
$sql_table = "`item`";
|
||||||
|
$sql_order = "`item`.`received`";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Here is the way permissions work in the search module...
|
// Here is the way permissions work in the search module...
|
||||||
|
@ -195,7 +198,7 @@ function search_content(&$a) {
|
||||||
OR ( `item`.`uid` = %d ))
|
OR ( `item`.`uid` = %d ))
|
||||||
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||||
$sql_extra
|
$sql_extra
|
||||||
ORDER BY `received` DESC LIMIT %d , %d ",
|
ORDER BY $sql_order DESC LIMIT %d , %d ",
|
||||||
intval(local_user()),
|
intval(local_user()),
|
||||||
intval($a->pager['start']),
|
intval($a->pager['start']),
|
||||||
intval($a->pager['itemspage'])
|
intval($a->pager['itemspage'])
|
||||||
|
|
Loading…
Reference in a new issue