diff --git a/Sources/Search.php b/Sources/Search.php index 028bf80c15..c200c1834f 100644 --- a/Sources/Search.php +++ b/Sources/Search.php @@ -1304,6 +1304,9 @@ function PlushSearch2() ), ); + // Most searches are at the topic-level, and do not list message-level results. + // Message-level results are displayed when doing searches within topics + // and when showing complete results ("Show results as messages" option). if (empty($search_params['topic']) && empty($search_params['show_complete'])) { $main_query['select']['id_topic'] = 't.id_topic'; @@ -1317,6 +1320,7 @@ function PlushSearch2() else { // This is outrageous! + // Note we're stuffing id_msg in an id_topic column to get past the db contraint. $main_query['select']['id_topic'] = 'm.id_msg AS id_topic'; $main_query['select']['id_msg'] = 'm.id_msg'; $main_query['select']['num_matches'] = '1 AS num_matches'; @@ -1851,7 +1855,8 @@ function PlushSearch2() $request = $smcFunc['db_search_query']('', ' SELECT ' . (empty($search_params['topic']) ? 'lsr.id_topic' : $search_params['topic'] . ' AS id_topic') . ', lsr.id_msg, lsr.relevance, lsr.num_matches FROM {db_prefix}log_search_results AS lsr' . ($search_params['sort'] == 'num_replies' || !empty($approve_query) ? ' - INNER JOIN {db_prefix}topics AS t ON (t.id_topic = lsr.id_topic)' : '') . ' + INNER JOIN {db_prefix}messages AS m ON (m.id_msg = lsr.id_msg) + INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)' : '') . ' WHERE lsr.id_search = {int:id_search}' . $approve_query . ' ORDER BY {raw:sort} {raw:sort_dir} LIMIT {int:start}, {int:max}',