Пример #1
0
    def search(self, query, limit=20):
        """Search in solr (if the solr feature is enabled) but then convert
        solr results to brains and continue working with them.

        Brains are obtained using path/rid which is expected to be performant
        enough. Search results are usually limited to 10.
        """
        if not is_solr_feature_enabled():
            for each in super(SolrObjPathSource, self).search(query,
                                                              limit=limit):
                yield each
            return

        results = self.solr.search(
            query=make_query(query),
            filters=self.make_solr_filters(self.selectable_filter.criteria),
            rows=limit,
            fl=['path'],
        )

        from opengever.base.solr import OGSolrContentListing  # XXX: FIXME!
        for solr_doc in OGSolrContentListing(results):
            brain = self._getBrainByToken(solr_doc.getPath())
            if brain:
                yield self.getTermByBrain(brain, real_value=False)
Пример #2
0
def reindex_object_security_without_children(obj):
    """Reindex only the security indices of the passed in object.

    Sometimes we know we do not need to also reindex the security of all the
    child objects, so we can directly go to what the upstream implementation
    does per object.

    As we're bypassing the normal machinery, likewise we need to do Solr
    indexing by hand.
    """
    catalog = api.portal.get_tool('portal_catalog')
    security_idxs = CatalogAware._cmf_security_indexes

    catalog.reindexObject(obj, idxs=security_idxs, update_metadata=False)

    if is_solr_feature_enabled():
        # Using catalogs reindexObject does not trigger corresponding solr
        # reindexing, so we do it manually.

        # Register collective.indexing hook, to make sure solr changes
        # are realy send to solr. See
        # collective.indexing.queue.IndexQueue.hook.
        getQueue().hook()

        processor = getUtility(IIndexQueueProcessor, name='ftw.solr')
        processor.index(obj, security_idxs)
Пример #3
0
 def enabled(self):
     return is_solr_feature_enabled()
Пример #4
0
 def _extend_terms_with_contacts(self, query_string):
     if is_solr_feature_enabled():
         self._extend_terms_with_contacts_from_solr(query_string)
     else:
         self._extend_terms_with_contacts_from_portal_catalog(query_string)