So we have a site using lineage, but the problem is present with multilingual sites as well: I want a vocabulary of all subjects (aka tags) used under a specific path.
Now its possible to get all items using a query and aggregate the Subjects from the results, but that is far from efficient.
Any other ideas? If not, then I need a good caching...
This product builds a tag portlet based on user-entered configuration and has an option to build a tag-cloud for a given section of a site, so perhaps you can reuse the code there, which also uses caching to save the data.
If waking up all the objects under the folder (witch I think as a deep nested structure) is out of question, the solution is to use another storage (e.g. a separate catalog, solr, a persistent object or even the annotations of the folder) to store the data.
Depending on what are you needs and your choices, you can meet several problems in order to manage edit/removals.
If this not viable the other solution is caching, which is actually storing your data in RAM.
I think a good way to get all the subjects under the path could be:
getting unique valuse for the subject index, i.e. portal_catalog._catalog.indexes['Subject']
making a search for every subject in your path and check you have some brains.