[Zope-CMF] Searching CMF returns all objects

Tres Seaver tseaver@zope.com
24 Apr 2002 11:42:01 -0400


On Wed, 2002-04-24 at 10:06, D.Turpie@open.ac.uk wrote:
> Hi
> 
> We have just upgraded Zope to version 2.5.0 and CMF version 1.2 and are
> having problems with searching.
> 
> No matter what search term we enter it seems to return everything that is in
> the catalogue.
> 
> I tried "Update Catalog" in the portal_catalog of the portal with no
> success.
> 
> Anyone got any ideas why this should be happening and a possible fix?

This sounds like a known problem when upgrading a catalog from Zope 2.3
to Zope 2.4+:  the indexes created under the older ZCatalog software
now don't do their job correctly.  The workaround is to delete and
recreate all the indexes in your catalog (at least the 'effective',
'expires', and 'allowedRolesAndUsers' indexes), and then reindex your
content, as in the following external method::

from Products.CMFCore.utils import getToolByName

def update_catalogIndexes(self, REQUEST):
    """
        Drop, re-add, and rebuild catalog Indexes for Zope CMF
        sites migrated Zope 2.3 to 2.4+.
    """
    CMF_CATALOG_INDEXES = (
        ( 'Creator',                     'Field Index'   )
        , ( 'Date',                        'Field Index'   )
        , ( 'Description',                 'Text Index'    )
        , ( 'PrincipiaSearchSource',       'Text Index'    )
        , ( 'SearchableText',              'Text Index'    )
        , ( 'Subject',                     'Keyword Index' )
        , ( 'Title',                       'Text Index'    )
        , ( 'Type',                        'Field Index'   )
        , ( 'allowedRolesAndUsers',        'Keyword Index' )
        , ( 'bobobase_modification_time',  'Field Index'   )
        , ( 'created',                     'Field Index'   )
        , ( 'effective',                   'Field Index'   )
        , ( 'end',                         'Field Index'   )
        , ( 'expires',                     'Field Index'   )
        , ( 'id',                          'Field Index'   )
        , ( 'in_reply_to',                 'Field Index'   )
        , ( 'meta_type',                   'Field Index'   )
        , ( 'modified',                    'Field Index'   )
        , ( 'reverse_modified',            'Field Index'   )
        , ( 'review_state',                'Field Index'   )
        , ( 'start',                       'Field Index'   )
        , ( 'title',                       'Text Index'    )
        )

    catalog = getToolByName( self, 'portal_catalog' )

    for index_name, index_type in CMF_CATALOG_INDEXES:
        catalog.delIndex( index_name )
        catalog.addIndex( index_name, index_type )

    catalog.manage_catalogReindex()

    return 'Catalog Indexes rebuilt.'


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