Фикс поиска

This commit is contained in:
Vitalychez 2015-01-28 15:34:31 +04:00
commit 87aeaf6fed
5 changed files with 16 additions and 14 deletions

View file

@ -483,7 +483,7 @@ $bb_cfg['max_post_length'] = 120000; // bytes
$bb_cfg['use_ajax_posts'] = true; $bb_cfg['use_ajax_posts'] = true;
// Search // Search
$bb_cfg['search_engine_type'] = 'mysql'; // none, mysql, sphinx $bb_cfg['search_engine_type'] = false; // true/false -> sphinx/mysql
$bb_cfg['sphinx_topic_titles_host'] = '127.0.0.1'; $bb_cfg['sphinx_topic_titles_host'] = '127.0.0.1';
$bb_cfg['sphinx_topic_titles_port'] = 3312; $bb_cfg['sphinx_topic_titles_port'] = 3312;
$bb_cfg['sphinx_config_path'] = realpath("../install/sphinx/sphinx.conf"); $bb_cfg['sphinx_config_path'] = realpath("../install/sphinx/sphinx.conf");

View file

@ -2233,19 +2233,21 @@ function log_sphinx_error ($err_type, $err_msg, $query = '')
} }
} }
function get_title_match_topics ($title_match_sql, $forum_ids = array()) function get_title_match_topics ($search)
{ {
global $bb_cfg, $sphinx, $userdata, $title_match, $lang; global $bb_cfg, $sphinx, $userdata, $lang;
$where_ids = array(); $where_ids = array();
if($forum_ids) $forum_ids = array_diff($forum_ids, array(0 => 0));
$title_match_sql = encode_text_match($title_match_sql); $forum_ids = (isset($search['ids']) && is_array($search['ids'])) ? array_diff($search['ids'], array(0 => 0)) : '';
$title_match_sql = encode_text_match($search['query']);
if ($bb_cfg['search_engine_type'] == 'sphinx') if ($bb_cfg['search_engine_type'])
{ {
init_sphinx(); init_sphinx();
$where = ($title_match) ? 'topics' : 'posts'; $where = (isset($search['topic_match'])) ? 'topics' : 'posts';
$sphinx->SetServer($bb_cfg['sphinx_topic_titles_host'], $bb_cfg['sphinx_topic_titles_port']); $sphinx->SetServer($bb_cfg['sphinx_topic_titles_host'], $bb_cfg['sphinx_topic_titles_port']);
if ($forum_ids) if ($forum_ids)
@ -2276,12 +2278,12 @@ function get_title_match_topics ($title_match_sql, $forum_ids = array())
log_sphinx_error('wrn', $warning, $title_match_sql); log_sphinx_error('wrn', $warning, $title_match_sql);
} }
} }
else if ($bb_cfg['search_engine_type'] == 'mysql') elseif(!$bb_cfg['search_engine_type'])
{ {
$where_forum = ($forum_ids) ? "AND forum_id IN(". join(',', $forum_ids) .")" : ''; $where_forum = ($forum_ids) ? "AND forum_id IN(". join(',', $forum_ids) .")" : '';
$search_bool_mode = ($bb_cfg['allow_search_in_bool_mode']) ? ' IN BOOLEAN MODE' : ''; $search_bool_mode = ($bb_cfg['allow_search_in_bool_mode']) ? ' IN BOOLEAN MODE' : '';
if($title_match) if(isset($search['topic_match']))
{ {
$where_id = 'topic_id'; $where_id = 'topic_id';
$sql = "SELECT topic_id FROM ". BB_TOPICS ." $sql = "SELECT topic_id FROM ". BB_TOPICS ."

View file

@ -516,7 +516,7 @@ if ($post_mode)
if ($text_match_sql) if ($text_match_sql)
{ {
$search_match_topics_csv = ''; $search_match_topics_csv = '';
$title_match_topics = get_title_match_topics($text_match_sql, $forum_selected); $title_match_topics = get_title_match_topics(array('query' => $text_match_sql, 'ids' => $forum_selected));
if (!$search_match_topics_csv = join(',', $title_match_topics)) if (!$search_match_topics_csv = join(',', $title_match_topics))
{ {
@ -714,7 +714,7 @@ else
if ($text_match_sql) if ($text_match_sql)
{ {
$search_match_topics_csv = ''; $search_match_topics_csv = '';
$title_match_topics = get_title_match_topics($text_match_sql, $forum_selected); $title_match_topics = get_title_match_topics(array('query' => $text_match_sql, 'ids' => $forum_selected));
if (!$search_match_topics_csv = join(',', $title_match_topics)) if (!$search_match_topics_csv = join(',', $title_match_topics))
{ {

View file

@ -558,7 +558,7 @@ if ($allowed_forums)
if ($title_match) if ($title_match)
{ {
$title_match_topics = get_title_match_topics($title_match_sql, $search_in_forums_ary); $title_match_topics = get_title_match_topics(array('query' => $title_match_val, 'ids' => array(0 => $forum_id)));
if (!$search_match_topics_csv = join(',', $title_match_topics)) if (!$search_match_topics_csv = join(',', $title_match_topics))
{ {

View file

@ -331,7 +331,7 @@ if ($title_match =& $_REQUEST[$title_match_key])
if ($tmp = mb_substr(trim($title_match), 0, $title_match_max_len)) if ($tmp = mb_substr(trim($title_match), 0, $title_match_max_len))
{ {
$title_match_val = clean_text_match($tmp, true, false, false); $title_match_val = clean_text_match($tmp, true, false, false);
$title_match_topics = get_title_match_topics($title_match_val, array(0 => $forum_id)); $title_match_topics = get_title_match_topics(array('query' => $title_match_val, 'ids' => array(0 => $forum_id), 'topic_match' => true));
if ($search_match_topics_csv = join(',', $title_match_topics)) if ($search_match_topics_csv = join(',', $title_match_topics))
{ {