[Zope-CMF] Searching portal_catalog using wildcards or regexp

Andreas Jung andreas@andreas-jung.com
Fri, 15 Nov 2002 08:12:59 +0100


--On Donnerstag, 14. November 2002 21:40 +0100 Dieter Maurer 
<dieter@handshake.de> wrote:

> Kevin Carlson writes:
>  > I have searched on zope.org to no avail -- is there a way in which I
> may  > query a portal_catalog for documents whose title begins with a
> certain  > letter?  For example, I would like to call something like this:
>  >
>  >     results = context.portal_catalog({'Title' : 'A*'})
>  >
>  > 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?
> This will work when "Title" is a "TextIndex" (I think, it is).
> However, it will then look for titles which contain a word beginning
> with "a" and not only titles that begin with "a".
>
> FieldIndex'es currently do not support wildcards. You would need
> to implement your own index. If you do, it is easy to plug it into
> the ZCatalog indexing framework.
>
>

The solution would be to break with the logic that index_id == 
indexed_attribute.
I proposed on zope-coders that all indexes of the Zope core in Zope 2.7 
should
be able to index multiple attributes. If necessary I can write an official
proposal but I will start on the implementation soon.

-aj