/** * Fetch list of ids by group_id. (For example - all posts by thread id) * * Attention(!) Selection by pure attributes is ineffective in sphinx. * There will be problems for mass threads rebuild. * * This code is for compatibility reasons, if optimised version * not implementer in index controler */ protected function _fetch_object_id_list($group_id, $only_first = false) { if (is_null($this->_content_type_id) or 0 == (int) $group_id) { return false; } $indexes = implode(",", vBSphinxSearch_Core::get_sphinx_index_map($this->_content_type_id)); if (empty($indexes)) { return false; } $limit = vBSphinxSearch_Core::SPH_DEFAULT_RESULTS_LIMIT; $query = 'SELECT * FROM ' . $indexes . ' WHERE contenttypeid = ' . $this->_content_type_id . ' AND groupid = ' . $group_id . ($only_first ? ' AND isfirst = 1' : '') . ' LIMIT ' . $limit . ' OPTION max_matches=' . $limit; $this->_id_list = array(); for ($i = 0; $i < vBSphinxSearch_Core::SPH_RECONNECT_LIMIT; $i++) { $con = vBSphinxSearch_Core::get_sphinxql_conection(); if (false != $con) { $result_res = mysql_query($query, $con); if ($result_res) { while ($docinfo = mysql_fetch_assoc($result_res)) { $this->_id_list[] = $docinfo['primaryid']; } return true; } } } $error = mysql_error(); $message = "\n\nSphinx: Can't get primaryid list for groupid={$group_id}\nUsed indexes: {$indexes}\n Error:\n{$error}\n"; vBSphinxSearch_Core::log_errors($message); return false; }
/** * Build list of indexes, required for used content types. * */ protected function _get_sphinx_indices($content_types = null) { $indexes = array(); if (!empty($content_types) and !is_array($content_types)) { $content_types = array(vB_Types::instance()->getContentTypeId($content_types)); } elseif (empty($content_types)) { global $vbulletin; // Additional setting for our product. // Show quick search results as snippets or as threads if ($vbulletin->options['sph_quick_search_results_as_post']) { // If show as threads - grouping required $this->_require_grouping = true; } } $collection = new vB_Collection_ContentType(); $collection->filterSearchable(true); foreach ($collection as $type) { $content_type_id = $type->getID(); if ($content_type_id == vB_Types::instance()->getContentTypeId('vBForum_Thread')) { // We use the same index for Posts & Threads $content_type_id = vB_Types::instance()->getContentTypeId('vBForum_Post'); } if (!empty($content_types) and !in_array($content_type_id, $content_types)) { continue; } $sphinx_index = vBSphinxSearch_Core::get_sphinx_index_map($content_type_id); if (!empty($sphinx_index)) { if ($this->_single_index_enabled) { $indexes[] = $sphinx_index[0]; } else { $indexes[] = implode(",", $sphinx_index); } } } return implode(", ", $indexes); }