[Zope-CMF] Searching portal_catalog using wildcards or regexp
Kevin Carlson
khcarlso@bellsouth.net
Thu, 14 Nov 2002 13:20:47 -0500
Thanks, Chris. This works fine. I am curious as to whether or not the
catalog will support regular expression searching in the future since adding
a new index to the catalog each time we want to program a new search method
seems a bit cumbersome. I understand the overhead involved with regexp --
even something similar to a LIKE operator in SQL would be nice. Thoughts
anyone?
Kevin
-----Original Message-----
From: zope-cmf-admin@zope.org [mailto:zope-cmf-admin@zope.org]On Behalf
Of Chris Withers
Sent: Thursday, November 14, 2002 6:27 AM
To: Kevin Carlson
Cc: zope-cmf@zope.org
Subject: Re: [Zope-CMF] Searching portal_catalog using wildcards or
regexp
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
_______________________________________________
Zope-CMF maillist - Zope-CMF@zope.org
http://lists.zope.org/mailman/listinfo/zope-cmf
See http://collector.zope.org/CMF for bug reports and feature requests