Example #1
0
    def run(self):
        """ Perform search and return results object """
        start = time.time()
        if self.request.cfg.xapian_search:
            hits = self._xapianSearch()
            logging.debug("_xapianSearch found %d hits" % len(hits))
        else:
            hits = self._moinSearch()
            logging.debug("_moinSearch found %d hits" % len(hits))

        # important - filter deleted pages or pages the user may not read!
        if not self.filtered:
            hits = self._filter(hits)
            logging.debug("after filtering: %d hits" % len(hits))

        # when xapian was used, we can estimate the numer of matches
        # Note: hits can't be estimated by xapian with historysearch enabled
        if not self.request.cfg.xapian_index_history and hasattr(self, '_xapianMset'):
            _ = self.request.getText
            mset = self._xapianMset
            m_lower = mset.get_matches_lower_bound()
            m_estimated = mset.get_matches_estimated()
            m_upper = mset.get_matches_upper_bound()
            estimated_hits = (m_estimated == m_upper and m_estimated == m_lower
                              and '' or _('about'), m_estimated)
        else:
            estimated_hits = None

        return getSearchResults(self.request, self.query, hits, start,
                self.sort, estimated_hits)
Example #2
0
 def _get_search_results(self, hits, start, estimated_hits):
     return getSearchResults(self.request, self.query, hits, start, self.sort, estimated_hits)