ZCatalog empty query fails silently

I have a brand new Zope 5.10 that works great except for one thing. I've indexed a few Folders in a ZCatalog called newCatalog with a few indexes and their corresponding metadata, and I can view the "Catalog records" by clicking on each record, but I can't get any results using this code:

<dtml-let results="newCatalog.searchResults()">
    <dtml-var "repr(results)">
    <dtml-var "_.len(results)">
    <dtml-in results>
        <dtml-var id>

has something changed? This works in older Zope versions.

What version of Zope did you upgrade from? The ZCatalog was changed in Products.ZCatalog version 4.0a2 (almost 8 years ago) to not return any results if the query is empty.

Instead, you can use catalog.getAllBrains() to get all of the items that are indexed, if you don't want to filter by any query. I don't know if this works in DTML or not.

1 Like

It's a fresh install and I just wanted to check that everything was working.

But I do occasionally need to send an empty query and your suggestion to use getAllBrains() does indeed work in DTML. Thanks for that.

Still, I was baffled by the silent failure. Am I the only one to have had this weird experience in the last eight years? Assuming that not to be the case, I've filed a PR to add some feedback for users coming from systems that do allow empty queries (Elasticsearch, Solr, Algolia...).

See: https://github.com/zopefoundation/Products.ZCatalog/pull/152