Search code examples
searchplonecatalog

Get a list of searchable content types in Plone 4


I am using Products.AdvancedQuery to build a replacement LiveSearch mechanism for my site. So far everything works perfectly, but the standard query performs a search on all available content-types, including the ones marked as non-searchable in the @@search-controlpanel.

I'd like AdvancedQuery to filter out the non-searchable ones dynamically, according to what is specified in @@search-controlpanel. How can I do this?

If AQ cannot do it, I can filter the results right after querying the catalog. I'd need a list of content-type names (or interfaces) that are marked as searchable. How can I obtain such a list?


Solution

  • Assuming you can obtain a tuple or list of the types that the control panel blacklists programmatically, this might be as simple as (imports elided):

    >>> query = myquery & AdvancedQuery.Not(AdvancedQuery.In(MY_TYPE_BLACKLIST_HERE)) 
    >>> result = getToolByName(context, 'portal_catalog').evalAdvancedQuery(query)