diff --git a/etc/sphinx.conf.in b/etc/sphinx.conf.in index 131a8496..d19c9633 100644 --- a/etc/sphinx.conf.in +++ b/etc/sphinx.conf.in @@ -89,10 +89,11 @@ source att : base source folder : base { sql_query_pre = SET NAMES utf8 - sql_query = select id, folder_id, message_id, uid FROM folder_message + sql_query = select id, folder_id, message_id, uid, 1 FROM folder_message sql_attr_uint = uid sql_attr_uint = folder_id + sql_attr_uint = message_id } index main1 diff --git a/webui/model/search/search.php b/webui/model/search/search.php index ea3df423..e092331c 100644 --- a/webui/model/search/search.php +++ b/webui/model/search/search.php @@ -217,7 +217,7 @@ class ModelSearchSearch extends Model { $num_rows = $query->num_rows; } else if(isset($data['folder']) && $data['folder']) { - $folder_id = 0; + $folder_id = -1; $folders = $session->get("folders"); @@ -227,7 +227,7 @@ class ModelSearchSearch extends Model { $folder_id = $folders[$data['folder']]; } - $query = $this->sphx->query("SELECT id FROM " . SPHINX_FOLDER_INDEX . " WHERE folder_id=$folder_id $sortorder LIMIT $offset,$pagelen OPTION max_matches=" . MAX_SEARCH_HITS); + $query = $this->sphx->query("SELECT message_id FROM " . SPHINX_FOLDER_INDEX . " WHERE folder_id=$folder_id $sortorder LIMIT $offset,$pagelen OPTION max_matches=" . MAX_SEARCH_HITS); $total_found = $query->total_found; $num_rows = $query->num_rows; } @@ -259,6 +259,7 @@ class ModelSearchSearch extends Model { if(isset($query->rows)) { foreach($query->rows as $a) { if(isset($a['mid'])) { array_push($ids, $a['mid']); } + else if(isset($a['message_id'])) { array_push($ids, $a['message_id']); } else { array_push($ids, $a['id']); } if($q) { $q .= ",?"; }