view MoinMoin/search/ @ 5044:f5f3d7348564

Xapian2009: Class Xapian.indexing.Index is renamed to XapianIndex. _check_version() was removed, xapian binding check is done by xappy. XapianSearch was moved to Log message is shown if xapian version is too old.
author Dmitrijs Milajevs <>
date Thu, 27 Aug 2009 18:46:31 +0300
parents f1d1d8105d52
children d77ac3c87ac8
line wrap: on
line source
# -*- coding: iso-8859-1 -*-
    MoinMoin - search engine

    @copyright: 2005 MoinMoin:FlorianFesti,
                2005 MoinMoin:NirSoffer,
                2005 MoinMoin:AlexanderSchremmer,
                2006 MoinMoin:ThomasWaldmann,
                2006 MoinMoin:FranzPletz
    @license: GNU GPL, see COPYING for details

from MoinMoin import log
logging = log.getLogger(__name__)

from import QueryParser, QueryError
from import MoinSearch

def searchPages(request, query, sort='weight', mtime=None, historysearch=None, **kw):
    """ Search the text of all pages for query.

    @param request: current request
    @param query: the expression (string or query objects) we want to search for
    @keyword sort: sorting of the search results, either 'weight' or 'page_name'
    @keyword mtime: only items modified since mtime
    @keyword historysearch: include older revisions of items in search
    @keyword titlesearch: treat all terms as title searches (passed to qp)
    @keyword case: do case sensitive search (passed to qp)
    @keyword regex: treat all terms as regular expression (passed to qp)
    @rtype: SearchResults instance
    @return: search results
    if isinstance(query, str) or isinstance(query, unicode):
        query = QueryParser(**kw).parse_query(query)

    searcher = MoinSearch

    if request.cfg.xapian_search:
            from import XapianSearch
            searcher = XapianSearch
        except ImportError, error:
            logging.warning("%s. Either disable Xapian completetly in your wikiconfig or upgrade your Xapian installation" % str(error))

    return searcher(request, query, sort, mtime=mtime, historysearch=historysearch).run()