Some CatalogTool methods ignore solr #5

reinhardt opened this Issue Sep 22, 2011 · 2 comments


None yet

2 participants


The methods


are not patched by collective.solr and thus work on the standard ZCatalog. Some methods, e.g. reindexObjectSecurity(), rely on them to reindex objects. When clearing the standard Catalog and using solr for all indexes, this fails silently because said methods get no results from ZCatalog and don't reindex anything.

By patching the methods like this we were able to fix the issue:

def unrestrictedSearchResults(self, REQUEST=None, **kw):
    kw = kw.copy()
    only_active = not kw.get('show_inactive', False)
    if only_active and not _checkPermission(AccessInactivePortalContent, self):
        kw['effectiveRange'] = DateTime()

    # support collective.indexing's "auto-flush" feature
    # see
    autoFlushQueue(hint='restricted/solr search', request=REQUEST, **kw)

    adapter = queryAdapter(self, ISearchDispatcher)
    if adapter is not None:
        return adapter(REQUEST, **kw)
        return self._cs_old_searchResults(REQUEST, **kw)

def reindexObject(self, object, idxs=[], update_metadata=1, uid=None):
        manager = queryUtility(ISolrConnectionManager)
        proc = SolrIndexProcessor(manager)
        proc.reindex(object, attributes=idxs or None)

def patchCatalogTool():
    """ monkey patch plone's catalogtool with the solr dispatcher """
    CatalogTool._cs_old_searchResults = CatalogTool.searchResults
    CatalogTool.searchResults = searchResults
    CatalogTool.unrestrictedSearchResults = unrestrictedSearchResults
    CatalogTool.reindexObject = reindexObject
    CatalogTool.__call__ = searchResults
hannosch commented Nov 1, 2011

I added the patch for unrestrictedSearchResults in db7afe2 - and fixed it to fall back on the unrestrictedSearchResults method of the catalog instead of searchResults.

hannosch commented Nov 1, 2011

Dispatching reindexObject is actually "wrong". This is a ZCatalog API, and we cannot simply ignore updating ZCatalog. Moving all indexes over to Solr is also not supported. You need at least the UID index in the ZCatalog.

But in general you probably don't want to loose transactional integrity for most queries, except for full text search.

@hannosch hannosch closed this Nov 1, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment