[Zope3-checkins] SVN: Zope3/trunk/src/zope/index/text/ Fix the reindexing in okapiindex.

Ignas Mikalajūnas ignas at pov.lt
Wed Apr 25 07:34:10 EDT 2007


Log message for revision 74747:
  Fix the reindexing in okapiindex.
  
  ( https://bugs.launchpad.net/zope3/+bug/109923 )
  

Changed:
  U   Zope3/trunk/src/zope/index/text/okapiindex.py
  U   Zope3/trunk/src/zope/index/text/textindex.txt

-=-
Modified: Zope3/trunk/src/zope/index/text/okapiindex.py
===================================================================
--- Zope3/trunk/src/zope/index/text/okapiindex.py	2007-04-25 11:26:02 UTC (rev 74746)
+++ Zope3/trunk/src/zope/index/text/okapiindex.py	2007-04-25 11:34:09 UTC (rev 74747)
@@ -229,9 +229,10 @@
         return count
 
     def _reindex_doc(self, docid, text):
+        old_docw = self._docweight[docid]
         count = BaseIndex._reindex_doc(self, docid, text)
         if count > -1:
-            self._totaldoclen -= self._docweight[docid]            
+            self._totaldoclen -= old_docw
         return count
 
     def unindex_doc(self, docid):

Modified: Zope3/trunk/src/zope/index/text/textindex.txt
===================================================================
--- Zope3/trunk/src/zope/index/text/textindex.txt	2007-04-25 11:26:02 UTC (rev 74746)
+++ Zope3/trunk/src/zope/index/text/textindex.txt	2007-04-25 11:34:09 UTC (rev 74747)
@@ -108,6 +108,17 @@
     >>> index.wordCount()
     114
 
+If we index the same document twice, once with a zero value, and then
+with a normal value, it should still work:
+
+    >>> index2 = TextIndex()
+    >>> index2.index_doc(1, [])
+    >>> index2.index_doc(1, ["Zorro"])
+
+    >>> [(k, "%.4f" % v) for (k, v) in index2.apply("Zorro").items()]
+    [(1, '0.4545')]
+
+
 Tracking Changes
 ================
 



More information about the Zope3-Checkins mailing list