[Zope] ZCatalog query

Jonathan Hobbs toolkit at magma.ca
Fri Aug 6 08:18:49 EDT 2004


----- Original Message -----
From: <jens.walte at kk.net>
> i search for a possibility to query a catalog like this:
>
> catalog({'meta_type':myobjecttype,
>          [x for x in 'keyword-index' if x.find(mysubstring) != -1]})
>
> Description:
> there is a metadata (keyword index) for urls in my catalog
> and i have to know the catalogentries with a matching substring in this
keyword-index
>
> Example:
> catalog-entry1 -> ['/abc/def/123', '/ghi/123']
> catalog-entry2 -> ['/ghi/123', '/abc']
> catalog-entry3 -> ['/xyz/def/123', '/ghi/123']
> and i search with '/abc' and wanna get entry1 and entry2


The form of query you created above is not supported by zcatalog.  To get
the results you seem to be looking for I suggest that you create a
ZCTextIndex and do a wildcard suffix search.

eg.  (search in python script)

searchterm = 'abc*'
searchresults = Catalog.searchResults({'newtextindex' : searchterm})
for res in searchresults:
   do something with results...

where, 'newtextindex' is a ZCTextIndex which was built using your metadata.

HTH

Jonathan




More information about the Zope mailing list