Mik*_*maa 4 full-text-search zope plone dexterity
我正在写一个Dexterity内容类型,其中包含纯文本和HTML字段.我想有一个自定义的SearchableText()方法,它将这些字段公开给portal_catalog和Plone全文搜索.
我假设纯文本我可以用空格进行字符串连接.但是当我在SearchableText()中公开它时,我应该如何预处理HTML内容?
为了在plone中转换数据,有一个名为portal_transforms的工具,它在转换内容时非常聪明(取决于你的操作系统/安装,它也可能能够转换.doc,.pdf等):
from Products.CMFCore.utils import getToolByName
transforms = getToolByName(self.context, 'portal_transforms')
stream = transforms.convertTo('text/plain', html, mimetype='text/html')
text = stream.getData().strip()
Run Code Online (Sandbox Code Playgroud)
为了在灵巧中索引字段我建议使用collective.dexteritytextindexer(但目前没有TTW支持).- > http://pypi.python.org/pypi/collective.dexteritytextindexer - > https://github.com/collective/collective.dexteritytextindexer
干杯
| 归档时间: |
|
| 查看次数: |
1113 次 |
| 最近记录: |