changeset 794:b7a31430bfc6

add wikiname to index, add comment about broken utf-8 queryparser
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 02 May 2006 13:23:39 +0200
parents a465544cff9a
children 1735cad0cd6c
files MoinMoin/Xapian.py MoinMoin/support/xapwrap/index.py
diffstat 2 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/Xapian.py	Tue May 02 02:18:21 2006 +0200
+++ b/MoinMoin/Xapian.py	Tue May 02 13:23:39 2006 +0200
@@ -232,6 +232,7 @@
             'pagename': 2,
             'attachment': 3,
             'mtime': 4,
+            'wikiname': 5,
         }
         self.prefixMap = { # http://svn.xapian.org/*checkout*/trunk/xapian-applications/omega/docs/termprefixes.txt
             'author': 'A',
@@ -278,7 +279,7 @@
                 timestamp = self.mtime()
                 break
             
-        hits = searcher.search(query, valuesWanted=['pagename', 'attachment', 'mtime', ])
+        hits = searcher.search(query, valuesWanted=['pagename', 'attachment', 'mtime', 'wikiname'])
         self.request.cfg.xapian_searchers.append((searcher, timestamp))
         return hits
     
@@ -411,7 +412,7 @@
                     _filter = mt2mn('application/octet-stream')
                     execute = wikiutil.importPlugin(request.cfg, 'filter', _filter)
                 except wikiutil.PluginMissingError:
-                    raise ImportError("Cannot load filter %s" % binaryfilter)
+                    raise ImportError("Cannot load filter %s" % _filter)
         try:
             data = execute(self, filename)
             if debug: request.log("Filter %s returned %d characters for file %s" % (_filter, len(data), filename))
@@ -455,6 +456,7 @@
             if debug: request.log("%s %r" % (filename, updated))
             if updated:
                 mimetype, file_content = self.contentfilter(filename)
+                wname = xapdoc.SortKey('wikiname', request.cfg.interwikiname or "Self")
                 pname = xapdoc.SortKey('pagename', fs_rootpage)
                 attachment = xapdoc.SortKey('attachment', filename) # XXX we should treat files like real pages, not attachments
                 mtime = xapdoc.SortKey('mtime', mtime)
@@ -464,7 +466,7 @@
                 content = xapdoc.TextField('content', file_content)
                 doc = xapdoc.Document(textFields=(content, mimetype, ),
                                       keywords=(title, ),
-                                      sortFields=(pname, attachment, mtime,),
+                                      sortFields=(pname, attachment, mtime, wname, ),
                                      )
                 doc.analyzerFactory = WikiAnalyzer
                 if mode == 'update':
@@ -505,6 +507,7 @@
             updated = True
         if debug: request.log("%s %r" % (pagename, updated))
         if updated:
+            wname = xapdoc.SortKey('wikiname', request.cfg.interwikiname or "Self")
             pname = xapdoc.SortKey('pagename', pagename)
             attachment = xapdoc.SortKey('attachment', '') # this is a real page, not an attachment
             mtime = xapdoc.SortKey('mtime', mtime)
@@ -515,7 +518,7 @@
             content = xapdoc.TextField('content', page.get_raw_body())
             doc = xapdoc.Document(textFields=(content, title),
                                   keywords=keywords,
-                                  sortFields=(pname, attachment, mtime,),
+                                  sortFields=(pname, attachment, mtime, wname, ),
                                  )
             doc.analyzerFactory = WikiAnalyzer
             #search_db_language = "english"
@@ -568,7 +571,7 @@
                 content = xapdoc.TextField('content', att_content)
                 doc = xapdoc.Document(textFields=(content, mimetype, ),
                                       keywords=(title, ),
-                                      sortFields=(pname, attachment, mtime,),
+                                      sortFields=(pname, attachment, mtime, wname, ),
                                      )
                 doc.analyzerFactory = WikiAnalyzer
                 if mode == 'update':
--- a/MoinMoin/support/xapwrap/index.py	Tue May 02 02:18:21 2006 +0200
+++ b/MoinMoin/support/xapwrap/index.py	Tue May 02 13:23:39 2006 +0200
@@ -862,6 +862,9 @@
     def __init__(self, queryString):
         if isinstance(queryString, unicode):
             queryString = queryString.encode(UNICODE_ENCODING, UNICODE_ERROR_POLICY)
+        # as of xapian 0.9.5 the query parser makes trouble with utf-8. but it
+        # also doesnt work with iso-8859-15, so we just live with ascii-only search
+        # for now... - a utf8 fix seems to be planned for the near future!
         self.queryString = queryString
 
     def prepare(self, queryParser):