[Zope-CMF] Searching portal_catalog using wildcards or regexp

Chris Withers chrisw@nipltd.com
Thu, 14 Nov 2002 11:27:11 +0000


Kevin Carlson wrote:
> 
> and have it return a result set for all documents where the Title index
> begins with the letter A.  Does anyone know if this can be done?

1. Create a FieldIndex called 'Title_firstletter'

2. Create a Script (Python) called 'Title_firstletter' and put it in your skin:

title = context.Title()
return title and title[0] or ''

3. re-index everything

4. perform your search like:

results = context.portal_catalog({'Title_firstletter' : 'A'})

cheers,

Chris