Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Private Member Functions
MoinMoin.search.Xapian.search.XapianSearch Class Reference
Inheritance diagram for MoinMoin.search.Xapian.search.XapianSearch:
Inheritance graph
[legend]
Collaboration diagram for MoinMoin.search.Xapian.search.XapianSearch:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def run

Public Attributes

 index
 request
 query
 sort
 mtime
 historysearch
 filtered
 fs_rootpage

Private Member Functions

def _xapian_index
def _search

Detailed Description

Definition at line 23 of file search.py.


Constructor & Destructor Documentation

def MoinMoin.search.Xapian.search.XapianSearch.__init__ (   self,
  request,
  query,
  sort = 'weight',
  mtime = None,
  historysearch = 0 
)
@param request: current request
@param query: search query objects tree
@keyword sort: the sorting of the results (default: 'weight')
@keyword mtime: only show items newer than this timestamp (default: None)
@keyword historysearch: whether to show old revisions of a page (default: 0)

Reimplemented from MoinMoin.search.builtin.BaseSearch.

Definition at line 25 of file search.py.

00025 
00026     def __init__(self, request, query, sort='weight', mtime=None, historysearch=0):
00027         super(XapianSearch, self).__init__(request, query, sort, mtime, historysearch)
00028 
00029         self.index = self._xapian_index()


Member Function Documentation

Search using Xapian

Get a list of pages using fast xapian search and
return moin search in those pages if needed.

Reimplemented from MoinMoin.search.builtin.BaseSearch.

Definition at line 42 of file search.py.

00042 
00043     def _search(self):
00044         """ Search using Xapian
00045 
00046         Get a list of pages using fast xapian search and
00047         return moin search in those pages if needed.
00048         """
00049         clock = self.request.clock
00050         index = self.index
00051 
00052         clock.start('_xapianSearch')
00053         clock.start('_xapianQuery')
00054         search_results = index.search(self.query, sort=self.sort, historysearch=self.historysearch)
00055         clock.stop('_xapianQuery')
00056         logging.debug("_xapianSearch: finds: %r" % search_results)
00057 
00058         # Note: .data is (un)pickled inside xappy, so we get back exactly what
00059         #       we had put into it at indexing time (including unicode objects).
00060         pages = [{'uid': r.id,
00061                   'wikiname': r.data['wikiname'][0],
00062                   'pagename': r.data['pagename'][0],
00063                   'attachment': r.data['attachment'][0],
00064                   'revision': r.data.get('revision', [0])[0]}
00065                  for r in search_results]
00066         try:
00067             if not self.query.xapian_need_postproc():
00068                 # xapian handled the full query
00069                 clock.start('_xapianProcess')
00070                 try:
00071                     _ = self.request.getText
00072                     return self._getHits(pages), (search_results.estimate_is_exact and '' or _('about'), search_results.matches_estimated)
00073                 finally:
00074                     clock.stop('_xapianProcess')
00075         finally:
00076             clock.stop('_xapianSearch')
00077 
00078         # some postprocessing by MoinSearch is required
00079         return MoinSearch(self.request, self.query, self.sort, self.mtime, self.historysearch, pages=pages)._search()
00080 
00081 

Here is the call graph for this function:

Get the xapian index if possible

@param request: current request

Definition at line 30 of file search.py.

00030 
00031     def _xapian_index(self):
00032         """ Get the xapian index if possible
00033 
00034         @param request: current request
00035         """
00036         index = XapianIndex(self.request)
00037 
00038         if not index.exists():
00039             raise IndexDoesNotExistError
00040 
00041         return index

def MoinMoin.search.builtin.BaseSearch.run (   self) [inherited]
Perform search and return results object 

Definition at line 258 of file builtin.py.

00258 
00259     def run(self):
00260         """ Perform search and return results object """
00261 
00262         start = time.time()
00263         hits, estimated_hits = self._search()
00264 
00265         # important - filter deleted pages or pages the user may not read!
00266         if not self.filtered:
00267             hits = self._filter(hits)
00268             logging.debug("after filtering: %d hits" % len(hits))
00269 
00270         return self._get_search_results(hits, start, estimated_hits)

Here is the call graph for this function:


Member Data Documentation

Reimplemented in MoinMoin.search.builtin.MoinSearch.

Definition at line 255 of file builtin.py.

Definition at line 256 of file builtin.py.

Definition at line 254 of file builtin.py.

Definition at line 28 of file search.py.

Definition at line 253 of file builtin.py.

Definition at line 251 of file builtin.py.

Definition at line 250 of file builtin.py.

Definition at line 252 of file builtin.py.


The documentation for this class was generated from the following file: