如何在Lucene.NET中按标签查找相关项目 [英] How to find related items by tags in Lucene.NET

查看:64
本文介绍了如何在Lucene.NET中按标签查找相关项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编入索引的文档有一个包含一组以竖线分隔的ID的字段:

My indexed documents have a field containing a pipe-delimited set of ids:

a845497737704e8ab439dd410e7f1328|
0a2d7192f75148cca89b6df58fcf2e54|
204fce58c936434598f7bd7eccf11771

(忽略换行符)

此字段代表标签列表.该列表可能包含 0 n 标签ID.

This field represents a list of tags. The list may contain 0 to n tag Ids.

当我的站点的用户查看特定文档时,我想显示相关文档的列表. 此相关文档列表必须由标签确定:

When users of my site view a particular document, I want to display a list of related documents. This list of related document must be determined by tags:

  • 只有带有至少一个匹配标签的文档才应出现在相关文档"列表中.
  • 标签匹配度最高的文档应显示在相关文档"列表的顶部.


我当时想为此使用WildcardQuery,但不允许以'*'开头的查询.


I was thinking of using a WildcardQuery for this but queries starting with '*' are not allowed.


有什么建议吗?


Any suggestions?

推荐答案

将Lucene可能用于此任务的时间搁置一分钟(我对此不太熟悉)-考虑签出LinkDatabase.

Setting aside for a minute the possible uses of Lucene for this task (which I am not overly familiar with) - consider checking out the LinkDatabase.

Sitecore将在后台跟踪您对项目的所有引用.而且,由于您确实是从多个标记的元层次结构中(我假设)选择了多个标记,这些标记表示为某个地方的Sitecore项目-LinkDatabase能够告诉您所有引用该项目的项目.

Sitecore will, behind the scenes, track all your references to and from items. And since your multiple tags are indeed (I assume) selected from a meta hierarchy of tags represented as Sitecore Items somewhere - the LinkDatabase would be able to tell you all items referencing it.

在某种伪代码模型中,这将变成

In some sort of pseudo code mockup, this would then become


for each ID in tags
  get all documents referencing this tag
  for each document found
    if master-list contains document; increase usage-count
    else; add document to master list
sort master-list by usage-count descending

请原谅我并不太精确,但是现阶段还无法模拟出一个可以正常工作的示例.

Forgive me that I am not more precise, but am unavailable to mock up a fully working example right at this stage.

您可以在此处找到有关LinkDatabase的文章 http://larsnielsen.blogspirit.com/tag/XSLT .请注意,如果您使用TreeListEx字段标记文档,则早期版本的Sitecore中存在已知的缺陷.在此处记录: http://www .cassidy.dk/blog/sitecore/2008/12/treelistex-not-registering-links-in.html

You can find an article about the LinkDatabase here http://larsnielsen.blogspirit.com/tag/XSLT. Be aware that if you're tagging documents using a TreeListEx field, there is a known flaw in earlier versions of Sitecore. Documented here: http://www.cassidy.dk/blog/sitecore/2008/12/treelistex-not-registering-links-in.html

这篇关于如何在Lucene.NET中按标签查找相关项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆