changeset 946:72aeb2ba133d

support complete rebuild of the index
author Franz Pletz <fpletz AT franz-pletz DOT org>
date Fri, 14 Jul 2006 15:12:34 +0200
parents 248789a3f155
children 41f6f7708466
files MoinMoin/script/index/build.py MoinMoin/search/Xapian.py MoinMoin/search/builtin.py docs/CHANGES.fpletz
diffstat 4 files changed, 21 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/script/index/build.py	Fri Jul 14 13:17:15 2006 +0200
+++ b/MoinMoin/script/index/build.py	Fri Jul 14 15:12:34 2006 +0200
@@ -22,7 +22,7 @@
         )
         self.parser.add_option(
             "--mode", metavar="MODE", dest="mode",
-            help="either add (unconditionally add to index) or update (update an existing index)"
+            help="either add (unconditionally add to index), update (update an existing index) or rebuild (remove and add)"
         )
     
     def mainloop(self):
@@ -40,5 +40,4 @@
     def command(self):
         from MoinMoin.search.Xapian import Index
         Index(self.request).indexPages(self.files, self.options.mode)
-        #Index(self.request).test(self.request)
 
--- a/MoinMoin/search/Xapian.py	Fri Jul 14 13:17:15 2006 +0200
+++ b/MoinMoin/search/Xapian.py	Fri Jul 14 15:12:34 2006 +0200
@@ -8,7 +8,7 @@
 """
 debug = True
 
-import sys, os, re, codecs, time
+import sys, os, re, codecs, time, os
 from pprint import pprint
 
 import xapian
@@ -237,6 +237,13 @@
             Assumes that the write lock is acquired
         """
         fs_rootpage = 'FS' # XXX FS hardcoded
+
+        # rebuilding the DB: delete it and add everything
+        if mode == 'rebuild':
+            for f in os.listdir(self.dir):
+                os.unlink(f)
+            mode = 'add'
+
         try:
             wikiname = request.cfg.interwikiname or 'Self'
             itemid = "%s:%s" % (wikiname, os.path.join(fs_rootpage, filename))
--- a/MoinMoin/search/builtin.py	Fri Jul 14 13:17:15 2006 +0200
+++ b/MoinMoin/search/builtin.py	Fri Jul 14 15:12:34 2006 +0200
@@ -149,7 +149,7 @@
         lock_dir = os.path.join(main_dir, 'index-lock')
         self.lock = lock.WriteLock(lock_dir,
                                    timeout=3600.0, readlocktimeout=60.0)
-        self.read_lock = lock.ReadLock(lock_dir, timeout=3600.0)
+        #self.read_lock = lock.ReadLock(lock_dir, timeout=3600.0)
         self.queue = UpdateQueue(os.path.join(main_dir, 'update-queue'),
                                  os.path.join(main_dir, 'update-queue-lock'))
 
@@ -172,12 +172,12 @@
         raise NotImplemented
 
     def search(self, query):
-        if not self.read_lock.acquire(1.0):
-            raise self.LockedException
-        try:
-            hits = self._search(query)
-        finally:
-            self.read_lock.release()
+        #if not self.read_lock.acquire(1.0):
+        #    raise self.LockedException
+        #try:
+        hits = self._search(query)
+        #finally:
+        #    self.read_lock.release()
         return hits
 
     def update_page(self, page):
--- a/docs/CHANGES.fpletz	Fri Jul 14 13:17:15 2006 +0200
+++ b/docs/CHANGES.fpletz	Fri Jul 14 15:12:34 2006 +0200
@@ -14,6 +14,9 @@
     * Indexing and searching of categories (new term prefix)
     * Reevaluate Xapwrap, possibly drop it and rip out usable stuff
       (i.e. ExceptionTranslator)
+    * Add stemming support for highlighting stuff:
+        1. regexp for whole word (all lowercase), or
+        2. just the root of the word
 
   New Features:
     * Faster search thanks to Xapian
@@ -143,4 +146,6 @@
 2006-07-14
     * Minor bugfix for TitleMatch, now works correctly
     * First interesting match must be a TextMatch
+    * Comment read_lock code from BaseIndex (should not be needed)
+    * Support complete rebuild of the database (delete and add)