Back to index

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

List of all members.

Public Member Functions

def highlight_re
def xapian_term
def __str__
def negate
def pageFilter
def search
def xapian_need_postproc
def __unicode__

Public Attributes

 search_re
 negated
 use_re
 case

Static Public Attributes

int costs = 10000

Private Member Functions

def _get_matches

Static Private Attributes

string _field_to_search = 'content'

Detailed Description

A term that does a normal text search

Both page content and the page title are searched, using an
additional TitleSearch term.

Definition at line 352 of file expressions.py.


Member Function Documentation

Definition at line 62 of file expressions.py.

00062 
00063     def __str__(self):
00064         return unicode(self).encode(config.charset, 'replace')

Reimplemented in MoinMoin.search.queryparser.expressions.AndExpression.

Definition at line 156 of file expressions.py.

00156 
00157     def __unicode__(self):
00158         neg = self.negated and '-' or ''
00159         return u'%s%s"%s"' % (neg, self._tag, unicode(self._pattern))
00160 

Reimplemented from MoinMoin.search.queryparser.expressions.BaseExpression.

Definition at line 365 of file expressions.py.

00365 
00366     def _get_matches(self, page):
00367         matches = []
00368 
00369         # Search in page name
00370         results = TitleSearch(self._pattern, use_re=self.use_re, case=self.case)._get_matches(page)
00371         if results:
00372             matches.extend(results)
00373 
00374         # Search in page body
00375         body = page.get_raw_body()
00376         for match in self.search_re.finditer(body):
00377             matches.append(TextMatch(re_match=match))
00378 
00379         return matches

Return a regular expression of what the term searches for

Used to display the needle in the page.

Reimplemented from MoinMoin.search.queryparser.expressions.BaseExpression.

Definition at line 362 of file expressions.py.

00362 
00363     def highlight_re(self):
00364         return u"(%s)" % self.pattern

Negate the result of this term 

Definition at line 65 of file expressions.py.

00065 
00066     def negate(self):
00067         """ Negate the result of this term """
00068         self.negated = 1

Return a page filtering function

This function is used to filter page list before we search
it. Return a function that get a page name, and return bool.

The default expression does not have any filter function and
return None. Sub class may define custom filter functions.

Reimplemented in MoinMoin.search.queryparser.expressions.TitleSearch, and MoinMoin.search.queryparser.expressions.AndExpression.

Definition at line 69 of file expressions.py.

00069 
00070     def pageFilter(self):
00071         """ Return a page filtering function
00072 
00073         This function is used to filter page list before we search
00074         it. Return a function that get a page name, and return bool.
00075 
00076         The default expression does not have any filter function and
00077         return None. Sub class may define custom filter functions.
00078         """
00079         return None

def MoinMoin.search.queryparser.expressions.BaseExpression.search (   self,
  page 
) [inherited]
Search a page

Returns a list of Match objects or None if term didn't find
anything (vice versa if negate() was called).  Terms containing
other terms must call this method to aggregate the results.
This Base class returns True (Match()) if not negated.

Reimplemented in MoinMoin.search.queryparser.expressions.OrExpression, and MoinMoin.search.queryparser.expressions.AndExpression.

Definition at line 83 of file expressions.py.

00083 
00084     def search(self, page):
00085         """ Search a page
00086 
00087         Returns a list of Match objects or None if term didn't find
00088         anything (vice versa if negate() was called).  Terms containing
00089         other terms must call this method to aggregate the results.
00090         This Base class returns True (Match()) if not negated.
00091         """
00092         logging.debug("%s searching page %r for (negated = %r) %r" % (self.__class__, page.page_name, self.negated, self._pattern))
00093 
00094         matches = self._get_matches(page)
00095 
00096         # Decide what to do with the results.
00097         if self.negated:
00098             if matches:
00099                 result = None
00100             else:
00101                 result = [Match()] # represents "matched" (but as it was a negative match, we have nothing to show)
00102         else: # not negated
00103             if matches:
00104                 result = matches
00105             else:
00106                 result = None
00107         logging.debug("%s returning %r" % (self.__class__, result))
00108         return result

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented in MoinMoin.search.queryparser.expressions.AndExpression.

Definition at line 153 of file expressions.py.

00153 
00154     def xapian_need_postproc(self):
00155         return self.case

def MoinMoin.search.queryparser.expressions.TextSearch.xapian_term (   self,
  request,
  connection 
)

Reimplemented from MoinMoin.search.queryparser.expressions.BaseTextFieldSearch.

Definition at line 380 of file expressions.py.

00380 
00381     def xapian_term(self, request, connection):
00382 
00383         content_query = super(TextSearch, self).xapian_term(request, connection)
00384         title_query = TitleSearch(self._pattern, use_re=self.use_re, case=self.case).xapian_term(request, connection)
00385 
00386         return Query(OP_OR, [title_query, content_query])
00387 


Member Data Documentation

Reimplemented from MoinMoin.search.queryparser.expressions.BaseTextFieldSearch.

Definition at line 360 of file expressions.py.

Definition at line 53 of file expressions.py.

Reimplemented from MoinMoin.search.queryparser.expressions.BaseExpression.

Definition at line 359 of file expressions.py.

Reimplemented in MoinMoin.search.queryparser.expressions.AndExpression.

Definition at line 51 of file expressions.py.

Reimplemented from MoinMoin.search.queryparser.expressions.BaseExpression.

Definition at line 347 of file expressions.py.

Definition at line 52 of file expressions.py.


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