标题和描述未使用 Collective.dexteritytextindexer 进行索引
我有很多 Dexterity 内容类型,其中一些只是容器,只留下标题和描述(来自 plone.app.dexterity.behaviors.metadata.IBasic 行为)。
我可以通过搜索标题或描述中的文本来找到它们。
但对于一些复杂的内容类型,我使用 collective.dexteritytextindexer 来索引更多字段和它工作正常,我可以在我标记为索引的字段上找到文本。
但是,标题和说明不再可用于搜索。我尝试了类似的操作:
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列上的标题和描述内容,因此结果没有显示它们。
知道我缺少什么吗?
干杯,
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.
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,
)
...
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.
Any idea what I'm missing?
Cheers,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
遇到了几乎同样的问题。遵循 http://pypi.python.org/pypi/collective.dexteritytextindexer 上的文档我曾经
为自己的字段建立索引。但是,该代码
不起作用。 IBasic 导入失败。看来这可以通过导入轻松解决
Got pretty much the same issue. Following the documentation on http://pypi.python.org/pypi/collective.dexteritytextindexer I used
to get my own fields indexed. However, the code
Didn't work. The import of IBasic fails. Seems this can easily be solved by importing
问题可能是该字段来自 IBasic 或 IDublineCore 行为,而不是来自您的架构。不过,我对 Collective.dexteritytextindexer 的了解还不够,不知道如何解决这个问题。
另一种选择可能是只使用 plone.indexer 并创建您自己的 SearchableText 索引器,该索引器返回 "%s %s %s" % (context.title, context.description, context.long_desc,)。有关详细信息,请参阅敏捷文档。
The problem is probably that the field is coming from the IBasic or IDublineCore behaviour and not from your schema. I don't know enough about collective.dexteritytextindexer to know how to work around this, though.
Another option may be to just use plone.indexer and create your own SearchableText indexer that returns "%s %s %s" % (context.title, context.description, context.long_desc,). See the Dexterity docs for details.
作为参考,这是我最终编写的代码:
As a reference this is the code I ended up writing: