ksuess
(Katja Süss)
April 14, 2025, 8:41am
1
Is text_strip(get_blocks_text(obj))
the way to go?
It works. I'm curious if this is recommended or if there is a better, performant suggestion.
from plone.restapi.indexers import get_blocks_text, text_strip
catalog = getToolByName(self.context, 'portal_catalog')
brains = catalog()
documents = []
for brain in brains:
obj = brain.getObject()
blocks_text = text_strip(get_blocks_text(obj))
1 Like
yurj
(Yuri)
April 14, 2025, 9:13am
2
What is the role of the catalog here? SearchableText is not stored in the metadata so you've to recalculate it. From the plone point of view, you should use the SearchableText
adapter that does basically the same + adding title, description and other fields. If you just want blocks, yes but you might have to consider IDynamicTextIndexExtender
:
Quick Update
Even though I got the school DataGridField field inside of the subform to index, searching for the school wasn't working.
Solution for searching for the subform field
I Added a custom SearchableTextExtender based on collective.dexteritytextindexer documentation.
from collective import dexteritytextindexer
from zope.component import adapts
from zope.interface import implements
class JaDMemberSearchableTextExtender(object):
adapts(IMember)
implements(dexteritytextindexer.I…
davisagli
(David Glick)
April 15, 2025, 1:07am
3
Yes, this is what the SearchableText indexer does for content with blocks.