Back to index

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

List of all members.

Public Member Functions

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

Public Attributes

 search_re
 negated
 use_re
 case

Static Public Attributes

int costs = 0

Private Attributes

 _pattern

Static Private Attributes

 _field_to_search = None

Detailed Description

Definition at line 309 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 

Return a regular expression of what the term searches for

Used to display the needle in the page.

Reimplemented in MoinMoin.search.queryparser.expressions.CategorySearch, MoinMoin.search.queryparser.expressions.LinkSearch, MoinMoin.search.queryparser.expressions.TextSearch, and MoinMoin.search.queryparser.expressions.AndExpression.

Definition at line 109 of file expressions.py.

00109 
00110     def highlight_re(self):
00111         """ Return a regular expression of what the term searches for
00112 
00113         Used to display the needle in the page.
00114         """
00115         return u''

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

Reimplemented in MoinMoin.search.queryparser.expressions.TextSearch.

Definition at line 313 of file expressions.py.

00313 
00314     def xapian_term(self, request, connection):
00315         if self.use_re:
00316             queries = [self._get_query_for_search_re(connection, self._field_to_search)]
00317         else:
00318             queries = []
00319             stemmed = []
00320             analyzer = Xapian.WikiAnalyzer(request=request, language=request.cfg.language_default)
00321 
00322             for term in self._pattern.split():
00323                 query_term = connection.query_field(self._field_to_search, term)
00324                 tokens = analyzer.tokenize(term)
00325 
00326                 if request.cfg.xapian_stemming:
00327                     query_token = []
00328                     for token, stemmed_ in tokens:
00329                         if token != term.lower():
00330                             if stemmed_:
00331                                 query_token.append(Query(OP_OR,
00332                                                          [connection.query_field(self._field_to_search, token),
00333                                                           connection.query_field(self._field_to_search, stemmed_)]))
00334 #                                 stemmed.append('(%s|%s)' % (token, stemmed_))
00335                             else:
00336                                 query_token.append(connection.query_field(self._field_to_search, token))
00337 #                                 stemmed.append(token)
00338                     query_tokens = Query(OP_AND, query_token)
00339                 else:
00340                     query_tokens = Query(OP_AND, [connection.query_field(self._field_to_search, token) for token, stemmed_ in tokens if token != term.lower()])
00341 
00342                 queries.append(Query(OP_OR, [query_term, query_tokens]))
00343 
00344             # XXX broken wrong regexp is built!
00345             if not self.case and stemmed:
00346                 new_pat = ' '.join(stemmed)
00347                 self._pattern = new_pat
00348                 self.pattern, self.search_re = self._build_re(new_pat, use_re=False, case=self.case, stemmed=True)
00349 
00350         return Query(OP_AND, queries)
00351 

Here is the call graph for this function:


Member Data Documentation

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

Definition at line 346 of file expressions.py.

Definition at line 53 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: