Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python/Plone: Getting all unique keywords (Subject)

Is there a way of getting all the unique keyword index i.e. Subject in Plone by querying the catalog?

I have been using this as a guide but not yet successful.

This is what I have so far

def search_content_by_keywords(self):
    """
    Attempting to search the catalog
    """
    catalog = self.context.portal_catalog
    query = {}
    query['Subject'] = 'Someval'        

    results = catalog.searchResults(query)
    return results

Instead of passing the keyword, I want to fetch all the keywords

like image 545
Frankline Avatar asked Jan 16 '23 17:01

Frankline


1 Answers

catalog = self.context.portal_catalog
my_keys = catalog.uniqueValuesFor('Subject')

reference: http://docs.plone.org/develop/plone/searching_and_indexing/query.html#unique-values

like image 70
Yuri Avatar answered Jan 30 '23 03:01

Yuri