标题和描述未使用Collective.dexteritytextindexer编制索引

编程入门 行业动态 更新时间:2024-10-23 20:25:37
本文介绍了标题和描述未使用Collective.dexteritytextindexer编制索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有很多敏捷内容类型,其中一些只是容器,只剩下标题和描述(来自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编制索引

本文发布于:2023-07-17 03:35:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1129012.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:索引   标题   Collective   dexteritytextindexer

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!