'The callback function handles the search results from SearchCommunity.
:param subject: Must be SIGNAL_SEARCH_COMMUNITY.
:param change_type: Must be SIGNAL_ON_SEARCH_RESULTS.
:param object_id: Must be None.
:param search_results: The result dictionary which has \'keywords\', \'results\', and \'candidate\'.'

@call_on_reactor_thread
def _on_torrent_search_results(self, subject, change_type, object_id, search_results):

    if (self.session is None):
        return 0
    keywords = search_results['keywords']
    results = search_results['results']
    candidate = search_results['candidate']
    self._logger.debug('Got    torrent    search    results    %s,    keywords    %s,    candidate    %s', len(results), keywords, candidate)
    if (keywords != self._current_keywords):
        return
    remote_torrent_result_list = []
    channel_cid_list = [result[(-1)] for result in results if (result[(-1)] is not None)]
    channel_cache_list = self.channelcast_db.getChannelsByCID(channel_cid_list)
    channel_cache_dict = {}
    for channel in channel_cache_list:
        channel_cache_dict[channel[1]] = channel
    for result in results:
        remote_torrent_result = {'torrent_type': 'remote', 'relevance_score': None, 'torrent_id': (-1), 'infohash': result[0], 'name': result[1], 'length': result[2], 'num_files': result[3], 'category': result[4][0], 'creation_date': result[5], 'num_seeders': result[6], 'num_leechers': result[7], 'status': u'good', 'query_candidates': {candidate}, 'channel': None}
        channel_cid = result[(-1)]
        if ((channel_cid is not None) and (channel_cid in channel_cache_dict)):
            channel = channel_cache_dict[channel_cid]
            channel_result = {'id': channel[0], 'name': channel[2], 'description': channel[3], 'dispersy_cid': channel[1], 'num_torrents': channel[4], 'num_favorite': channel[5], 'num_spam': channel[6], 'modified': channel[8]}
            remote_torrent_result['channel'] = channel_result
        keyword_set = set(keywords)
        swarmname_set = set(split_into_keywords(remote_torrent_result['name']))
        matches = {'fileextensions': set(), 'swarmname': (swarmname_set & keyword_set)}
        matches['filenames'] = (keyword_set - matches['swarmname'])
        if (len(matches['filenames']) == 0):
            (_, ext) = os.path.splitext(result[0])
            ext = ext[1:]
            matches['filenames'] = matches['swarmname']
            matches['filenames'].discard(ext)
            if (ext in keyword_set):
                matches['fileextensions'].add(ext)
        pos_score = None
        if matches['swarmname']:
            swarmnameTerms = split_into_keywords(remote_torrent_result['name'])
            swarmnameMatches = matches['swarmname']
            for (i, term) in enumerate(swarmnameTerms):
                if (term in swarmnameMatches):
                    pos_score = (- i)
                    break
        remote_torrent_result['relevance_score'] = [len(matches['swarmname']), pos_score, len(matches['filenames']), len(matches['fileextensions']), 0]
        remote_torrent_result_list.append(remote_torrent_result)
    results_data = {'keywords': keywords, 'result_list': remote_torrent_result_list}
    self.session.notifier.notify(SIGNAL_TORRENT, SIGNAL_ON_SEARCH_RESULTS, None, results_data)
