[Zope-CMF] reindexObject problem

Tres Seaver tseaver@zope.com
06 Mar 2003 08:51:02 -0500


On Wed, 2003-03-05 at 13:25, Yuppie wrote:

> Using TextIndexNG, reindexObject doesn't delete words from the index 
> that are deleted from SearchableText.

This is a bug in the index.  Reindexing a document should fix up both
the "forward" indexes (from value to UID) and the "reverse" indexes
(from UID back to value).  Unindexing is *not* supposed to happen for
objects whose UID is still valid.

> First I thought this is a bug in TextIndexNG.
> 
> But than I found this in ZCatalog.CatalogAwareness:
> 
>      def reindex_object(self):
>          self.unindex_object()      # calls uncatalog_object
>          self.index_object()        # calls catalog_object
> 
> and this in CatalogTool.CatalogTool:
> 
>      def reindexObject(self, object, idxs=[]):
>          url = self.__url(object)
>          ## Zope 2.3 ZCatalog is supposed to work better if
>          ## you don't uncatalog_object() when reindexing.
>          # self.uncatalog_object(url)
>          [...]
>          self.catalog_object(object, url, idxs=idxs)
> 
> 
> So now I think the reindex method is responsible for unindexing before 
> reindexing. CMF doesn't support Zope 2.3 anyway, so maybe 
> self.uncatalog_object(url) should be uncommented.
> (Well, we can't do that if we reindex only some indxs.)

That is a fossil, and likely a *huge* performance drag if it is actually
being called.  Reindexing should *not* unindex first;  the only time
an object should be unindexed is when its UID (the physical path in most
cases) is no longer valid (i.e., it has moved or been deleted).

The tool is doing the Right Thing (TM) by not uncataloguing first. Can
you determine whether CatalogAwareness.reindex_object is ever actually
called?  We should probably just remove it, in any case.

Tres.
-- 
===============================================================
Tres Seaver                                tseaver@zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com