changeset 1195:d40445ea30af

bugfixes for regexp & link search and file indexing (i.e. due to xapwrap modifications)
author Franz Pletz <fpletz AT franz-pletz DOT org>
date Fri, 21 Jul 2006 01:45:07 +0200
parents 7746d74fda4f
children 98b9469ce6ac
files MoinMoin/search/Xapian.py MoinMoin/search/builtin.py MoinMoin/search/queryparser.py docs/CHANGES.fpletz
diffstat 4 files changed, 18 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/search/Xapian.py	Thu Jul 20 20:21:31 2006 +0200
+++ b/MoinMoin/search/Xapian.py	Fri Jul 21 01:45:07 2006 +0200
@@ -249,7 +249,7 @@
             mtime = wikiutil.timestamp2version(mtime)
             if mode == 'update':
                 query = xapidx.RawQuery(xapdoc.makePairForWrite('itemid', itemid))
-                docs = writer.search(query, valuesWanted=['pagename', 'attachment', 'mtime', 'wikiname', ])
+                enq, docs = writer.search(query, valuesWanted=['pagename', 'attachment', 'mtime', 'wikiname', ])
                 if docs:
                     doc = docs[0] # there should be only one
                     uid = doc['uid']
@@ -338,7 +338,7 @@
             # you can just call database.replace_document(uid_term, doc)
             # -> done in xapwrap.index.Index.index()
             query = xapidx.RawQuery(xapdoc.makePairForWrite('itemid', itemid))
-            docs = writer.search(query, valuesWanted=['pagename', 'attachment', 'mtime', 'wikiname', ])
+            enq, docs = writer.search(query, valuesWanted=['pagename', 'attachment', 'mtime', 'wikiname', ])
             if docs:
                 doc = docs[0] # there should be only one
                 uid = doc['uid']
@@ -387,7 +387,7 @@
             mtime = wikiutil.timestamp2version(os.path.getmtime(filename))
             if mode == 'update':
                 query = xapidx.RawQuery(xapdoc.makePairForWrite('itemid', att_itemid))
-                docs = writer.search(query, valuesWanted=['pagename', 'attachment', 'mtime', ])
+                enq, docs = writer.search(query, valuesWanted=['pagename', 'attachment', 'mtime', ])
                 if debug: request.log("##%r %r" % (filename, docs))
                 if docs:
                     doc = docs[0] # there should be only one
--- a/MoinMoin/search/builtin.py	Thu Jul 20 20:21:31 2006 +0200
+++ b/MoinMoin/search/builtin.py	Fri Jul 21 01:45:07 2006 +0200
@@ -15,7 +15,7 @@
 from MoinMoin.Page import Page
 from MoinMoin.util import filesys, lock
 from MoinMoin.search.results import getSearchResults
-from MoinMoin.search.queryparser import TextMatch, TitleMatch
+from MoinMoin.search.queryparser import Match, TextMatch, TitleMatch
 
 ##############################################################################
 # Search Engine Abstraction
@@ -439,9 +439,14 @@
                         len(positions[pos]) < len(term_name):
                     positions[pos] = term_name
             term.next()
-        return [self._xapianMatchDecider(term, pos) for pos, term
+        matches = [self._xapianMatchDecider(term, pos) for pos, term
             in positions.iteritems()]
 
+        if not matches:
+            return [Match()]    # dummy for metadata, we got a match!
+
+        return matches
+
     def _moinSearch(self, pages=None):
         """ Search pages using moin's built-in full text search 
         
--- a/MoinMoin/search/queryparser.py	Thu Jul 20 20:21:31 2006 +0200
+++ b/MoinMoin/search/queryparser.py	Fri Jul 21 01:45:07 2006 +0200
@@ -309,7 +309,7 @@
             terms = [term for term in allterms() if
                     self.search_re.match(term)]
             if not terms:
-                return None
+                return Query()
             queries = [Query(Query.OP_OR, terms)]
         else:
             analyzer = Xapian.WikiAnalyzer(request=request,
@@ -414,9 +414,9 @@
         if self.use_re:
             # basic regex matching per term
             terms = [term for term in allterms() if
-                    self.search_re.match(term)]
+                    self.search_re.findall(term[1:]) and term[0] == 'S']
             if not terms:
-                return None
+                return Query()
             queries = [Query(Query.OP_OR, terms)]
         else:
             analyzer = Xapian.WikiAnalyzer(request=request,
@@ -540,7 +540,7 @@
                     continue
 
             if not terms:
-                return None
+                return Query()
             return Query(Query.OP_OR, terms)
         else:
             return UnicodeQuery('%s:%s' % (prefix, self.pattern))
@@ -601,7 +601,7 @@
                     continue
 
             if not terms:
-                return None
+                return Query()
             return Query(Query.OP_OR, terms)
         else:
             pattern = self.pattern
--- a/docs/CHANGES.fpletz	Thu Jul 20 20:21:31 2006 +0200
+++ b/docs/CHANGES.fpletz	Fri Jul 21 01:45:07 2006 +0200
@@ -4,7 +4,8 @@
   Known main issues:
     * Only term-based regex searching possible, modifier or heuristic to
       enable usage of _moinSearch for full compatibility?
-    * HACK: MoinMoin.Xapian.Index._get_languages (wait for proper metadata)
+    * HACK: MoinMoin.search.Xapian.Index._get_languages (wait for proper
+      metadata)
     * Positions saved in Xapian aren't always correct, check. Code
       generally needs some more love.
 
@@ -170,5 +171,5 @@
     * student didn't work on the project -- ThomasWaldmann
 
 2006-07-20
-    * ...
+    * Fixed some bugs found while testing regexp and case-sensitive searches