Portal Catalog Query with Wildcard *

Hi,
i would like perform a search in the portal catalog. I would get all Results with the Title starts with an "A". I do this with the following statement:

brains = catalog.searchResults({
    'portal_type': 'Document',
    'Title': 'A*',
    'sort_on':'sortable_title',
    'sort_order': 'ascending'})

My brains contain many expectable results but i get also brains with title e.g. "Schule am Klinikum". You can see, that the Result starts not with "A". I think the word in the middle starts with "A" and the catalog query match also this. Is this a Bug or is this a normal Behavior? Is there a possibility to do this search with "Onboard" Functions of Catalog or should i filter the Results with e.g. Python String Function startswith?

2 Likes

brains = [brain for brain in brains if brain.Title.startswith('A')]

should work as post-filter or you create a special field index in Zcatalog that would index only the first letter of the title...then you can query is particular index by a single letter (if you want to achieve something like an A-Z listing).

-aj