我有很多敏捷内容类型,其中一些只是容器,只剩下标题和描述(来自plone.app.dexterity.behaviors.metadata.IBasic行为).
I have lots of Dexterity content types, some of them are just containers and are left with just the Title and Description (from plone.app.dexterity.behaviors.metadata.IBasic behavior).
我可以通过搜索标题或描述中的文本来找到它们.
I can find them by searching the text inside their title or description.
但是对于某些复杂的内容类型,我正在使用 collective.dexteritytextindexer 为某些内容建立索引更多字段,并且效果很好,我可以在我标记为要索引的字段上找到文本.
But for some complex content types I'm using collective.dexteritytextindexer to index some more fields and it works fine, I can find the text on the fields I marked to be indexed.
但是标题和描述不再可用于搜索.我尝试过类似的事情:
However the Title and Description are no longer available for searching. I tried something like:
class IMyContent(form.Schema): """My content type description """ dexteritytextindexer.searchable('title') dexteritytextindexer.searchable('description') dexteritytextindexer.searchable('long_desc') form.widget(long_desc = WysiwygFieldWidget) long_desc = schema.Text ( title = _(u"Rich description"), description = _(u"Complete description"), required = False, ) ...但是我在portal_catalog的SearchableText列上看不到标题和描述的内容,因此结果没有显示出来.
But I can't see the content of title and description on the SearchableText column in the portal_catalog, and thus the results don't show them.
知道我缺少什么吗?
干杯
推荐答案作为参考,这是我最终编写的代码:
As a reference this is the code I ended up writing:
@indexer(IMyDexterityType) def searchableIndexer(context): transforms = getToolByName(context, 'portal_transforms') long_desc = context.long_desc // long_desc is a rich text field if long_desc is not None: long_desc = transforms.convert('html_to_text', long_desc).getData() contacts = context.contacts // contacts is also a rich text field if contacts is not None: contacts = transforms.convert('html_to_text', contacts).getData() return "%s %s %s %s" % (context.title, context.description, long_desc, contacts,) grok.global_adapter(searchableIndexer, name="SearchableText")更多推荐
标题和描述未使用Collective.dexteritytextindexer编制索引
发布评论