Improve the search

Improve the search speed
This commit is contained in:
Danang Probo Sayekti 2014-02-11 15:30:52 +07:00
commit d8cbaefad2
2 changed files with 41 additions and 80 deletions

View file

@ -939,12 +939,9 @@ get('/search/:keyword', function($keyword){
$page = $page ? (int)$page : 1;
$perpage = config('search.perpage');
$posts = get_keyword($keyword);
$posts = get_keyword($keyword, $page, $perpage);
$total = count($posts);
// Extract a specific page with results
$posts = array_slice($posts, ($page-1) * $perpage, $perpage);
$total = keyword_count($keyword);
if(empty($posts) || $page < 1){
// a non-existing page