如何在 Django Haystack 中访问/配置摘要/片段
我正在努力在我的网站上设置 django-haystack,并尝试在我的搜索结果中包含片段,大致如下:
关于 Wikis
结果一的标题 ...wiki 值的特殊之处在于...我总是使用当我走路时有一个 wiki...片段值三也谈论 wiki...这是另一个片段值 关于维基。
我知道有一个模板标签使用 Haystack 代码来突出显示,但它生成的片段非常有限:
- 它们总是以查询词开头
- ,只有一个片段值,
- 它们不支持星号查询
- 和其他内容?
有没有办法使用 Solr 后端生成如上所示的正确片段?
I'm working on getting django-haystack set up on my site, and am trying to have snippets in my search results roughly like so:
Title of result one about Wikis
...this special thing about wiki values is that...I always use a wiki when I walk...snippet value three talks about wikis too...and here's another snippet value
about wikis.
I know there's a template tag that uses Haystack code to do the the highlighting, but the snippets it generates are pretty limited:
- they always start with the query word
- there's only one snippet value
- they don't support asterisk queries
- and other stuff?
Is there a way to use the Solr backend to generate proper snippets as shown above?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
底线是 Haystack 无法真正以灵活的方式使用 Solr 突出显示。我在 IRC 上与 Haystack 的主要开发人员进行了交谈,他基本上说,如果我想要获得我正在寻找的那种突出显示,获得它的唯一方法是扩展 Haystack 使用的 Solr 后端。
我涉足了大约半天,但无法让 Haystack 识别我的自定义后端。 Haystack 有一些神奇的后端加载代码,但对我来说不起作用。
因此,我已切换到 sunburnt,它为 Solr 提供了一个更轻量级且更可扩展的包装器。我希望它会表现得更好。
Bottom line is that the Solr highlighting can't really be used by Haystack in a flexible way. I spoke to the main developer for Haystack on IRC, and he said basically, if I want to have the kind of highlighting I'm looking for, the only way to get it is to extend the Solr backend that Haystack uses.
I dabbled in that for about half a day, but couldn't get Haystack to recognize my custom back end. Haystack has some magic backend loading code that just wasn't working with me.
Consequently, I've switched over to sunburnt, which provides a lighter-weight and more extensible wrapper around Solr. I'm hoping it will fare better.
http://docs.haystacksearch.org/dev/highlighting.html
http://docs.haystacksearch.org/dev/highlighting.html