changeset 5005:dbec2f99c0dc

Xapian2009: BaseExpression._get_query_for_search_re() now checks all field values, not only the first one. xapian_term() returns not empty queries for link:re: and link:re:case:. Categories are stored as they are, they are not lowercased. Comment why xapian_term for category:re: does not work is added.
author Dmitrijs Milajevs <dimazest@gmail.com>
date Fri, 14 Aug 2009 00:33:32 +0200
parents bb2317d4984b
children 8e0a95b9508a
files MoinMoin/search/Xapian.py MoinMoin/search/queryparser.py
diffstat 2 files changed, 13 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/search/Xapian.py	Thu Aug 13 22:49:47 2009 +0200
+++ b/MoinMoin/search/Xapian.py	Fri Aug 14 00:33:32 2009 +0200
@@ -424,7 +424,7 @@
         if not prev or prev == 1:
             return []
         # for CategoryFoo, group 'all' matched CategoryFoo, group 'key' matched just Foo
-        return [m.group('all').lower() for m in self.request.cfg.cache.page_category_regex.finditer(body[pos:])]
+        return [m.group('all') for m in self.request.cfg.cache.page_category_regex.finditer(body[pos:])]
 
     def _get_domains(self, page):
         """ Returns a generator with all the domains the page belongs to
--- a/MoinMoin/search/queryparser.py	Thu Aug 13 22:49:47 2009 +0200
+++ b/MoinMoin/search/queryparser.py	Fri Aug 14 00:33:32 2009 +0200
@@ -118,15 +118,15 @@
             if field_to_check:
                 # Check only field with given name
                 if field_to_check in data:
-                    term = data[field_to_check][0]
-                    if self.search_re.match(term):
-                        queries.append(connection.query_field(field_to_check, term))
+                    for term in data[field_to_check]:
+                        if self.search_re.match(term):
+                            queries.append(connection.query_field(field_to_check, term))
             else:
                 # Check all fields
-                for field, value in data.iteritems():
-                    term = value[0]
-                    if self.search_re.match(term):
-                        queries.append(connection.query_field(field, term))
+                for field, terms in data.iteritems():
+                    for term in terms:
+                        if self.search_re.match(term):
+                            queries.append(connection.query_field(field_to_check, term))
 
         return Query(Query.OP_OR, queries)
 
@@ -713,8 +713,11 @@
                   directly below some comment lines.
         """
         kwargs['use_re'] = True
+        # XXX This breaks xapian_term because xapian index stores just categories (without "-----").
+        # Thus, self._get_query_for_search_re() can not mach anything, and empty query is returned.
         TextSearch._build_re(self,
-                r'(?m)(^-----*\s*\r?\n)(^##.*\r?\n)*^(?!##)(.*)\b%s\b' % pattern, **kwargs)
+                             r'(?m)(^-----*\s*\r?\n)(^##.*\r?\n)*^(?!##)(.*)\b%s\b' % pattern,
+                             **kwargs)
 
     def costs(self):
         return 5000 # cheaper than a TextSearch
@@ -734,7 +737,7 @@
         if self.use_re:
             return self._get_query_for_search_re(connection, 'category')
         else:
-            pattern = self._pattern.lower()
+            pattern = self._pattern
             # XXX UnicodeQuery was used
             return connection.query_field('category', pattern)