13
13
from MoinMoin import log
14
14
logging = log.getLogger(__name__)
16
from MoinMoin.search.queryparser import QueryParser, QueryError
17
from MoinMoin.search.builtin import MoinSearch
16
from MoinMoin.search.queryparser import QueryParser
17
from MoinMoin.search.builtin import Search
20
19
def searchPages(request, query, sort='weight', mtime=None, historysearch=None, **kw):
22
Search the text of all pages for query.
20
""" Search the text of all pages for query.
24
22
@param request: current request
25
23
@param query: the expression (string or query objects) we want to search for
32
30
@rtype: SearchResults instance
33
31
@return: search results
35
return _get_searcher(request, query, sort, mtime, historysearch, **kw).run()
38
def _get_searcher(request, query, sort='weight', mtime=None, historysearch=None, **kw):
40
Return a searcher object according to the configuration.
42
query = _parse_query(query, **kw)
45
if request.cfg.xapian_search:
47
from MoinMoin.search.Xapian.search import XapianSearch, IndexDoesNotExistError
48
searcher = XapianSearch(request, query, sort, mtime=mtime, historysearch=historysearch)
49
except ImportError, error:
50
logging.warning("%s. You should either set xapian_search = False in your wiki config or install/upgrade Xapian." % str(error))
51
except IndexDoesNotExistError:
52
logging.warning("Slow moin search is used because the Xapian index does not exist. You should create it using the moin index build command.")
55
searcher = MoinSearch(request, query, sort, mtime=mtime, historysearch=historysearch)
59
def _parse_query(query, **kw):
60
33
if isinstance(query, str) or isinstance(query, unicode):
61
34
query = QueryParser(**kw).parse_query(query)
35
return Search(request, query, sort, mtime=mtime,
36
historysearch=historysearch).run()