Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Some CatalogTool methods ignore solr #5

Closed
reinhardt opened this Issue September 22, 2011 · 2 comments

2 participants

Manuel Reinhardt Hanno Schlichting
Manuel Reinhardt

The methods

CatalogTool.unrestrictedSearchResults()
CatalogTool.reindexObject()

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 http://dev.plone.org/collective/changeset/73602
    autoFlushQueue(hint='restricted/solr search', request=REQUEST, **kw)

    adapter = queryAdapter(self, ISearchDispatcher)
    if adapter is not None:
        return adapter(REQUEST, **kw)
    else:
        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)
        proc.commit()

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
Hanno Schlichting
Owner

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

Hanno Schlichting
Owner

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.

Hanno Schlichting hannosch closed this November 01, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.