如何索引论坛讨论以进行搜索?

发布于 2024-09-24 15:59:56 字数 96 浏览 8 评论 0 原文

对于讨论论坛,将讨论线程中的每个条目索引为单独的 lucene 文档,还是将讨论中的所有条目简单地连接到一大块文本中,并将整个讨论线程索引为单个 lucene 文档,效果更好吗?

For a discussion forum, does it work better to index each entry inside a discussion thread as a separate lucene document or simple concat all entries within a discussion into one big block of text and index a whole discussion thread as a single lucene document?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

雪花飘飘的天空 2024-10-01 15:59:57

取决于您正在寻找什么样的搜索功能。例如,如果您希望用户能够搜索某个特定日期的线程中出现的关键字,那么您必须将所有条目索引为带有日期的单独文档(如 NumericField 可使用 NumericRangeFilter)。

将每个条目作为单独的文档进行索引还将使您能够使用 Lucene 评分器对每个条目进行评分,这将有助于检索最相关的条目(而不是线程)作为对查询的响应。此外,您还可以将主题作为单独的字段添加到每个条目文档中(以多一点空间为代价)。

如果您想将用户指向感兴趣的确切条目,那么连接所有条目并不是一个好主意。
至于您对从同一线程返回多个条目的担忧(对 Ryan 的回答进行评论),您可以在索引时向每个条目添加一个线程 id。然后在显示结果时,您可以仅显示每个线程 id 的条目(得分最高的条目可以与线程主题一起显示)

Depends on what kind of search capabilities you are looking for. For eg, if you want the users to be able to search for keywords that occurred in threads on some particular date, then you must index all entries as separate documents with a date (as a NumericField searchable using a NumericRangeFilter).

Indexing every entry as a separate document will also enable you to score each entry using the Lucene scorers which will help in retrieving the most relevant entries (and not threads) as a response to a query. Additionally you can also add the thread topic as a separate field to each entry-document (at the cost of little more space).

Concatenating all entries is not a good idea if you want to point the user to the exact entry of interest.
As to your concern(comment on Ryan's answer) on returning multiple entries from the same thread, you can add a thread id to each entry while indexing. Then at the time of displaying results you can display only the entry for each thread id (the entry with the highest score could be displayed along with the thread topic)

肤浅与狂妄 2024-10-01 15:59:57

如果您连接讨论中的所有条目,您会遇到错误,无法精确指出要检索的确切条目。

Lucene 应该能够快速索引和搜索每个条目(帖子/线程/其他)。将它们混在一起似乎有些过分了。

If you concatenate all entries within a discussion you run into the error where you cannot pin point the exact entry you want to retrieve.

Lucene should be able to quickly index and search each entry (post/thread/whatever). Mashing them all together just seems overkill.

慕烟庭风 2024-10-01 15:59:57

如果您决定单独索引它们,可以使用 Solr,它将支持搜索结果折叠:

http://www.lucidimagination.com/blog/2010/09/16/2446/

If you decide to index them separately, you can use Solr, which is about to support search result collapsing:

http://www.lucidimagination.com/blog/2010/09/16/2446/

很糊涂小朋友 2024-10-01 15:59:57

我更喜欢单独索引每个条目。这将使设计更加灵活,因为您的系统应该有某种主题实体来将条目分组到同一线程中。使用串联建立索引的另一个问题是,一旦发布新条目,就需要重新索引,这会影响性能。

I will prefer to index each entry separately. It will make the design more flexible as your system should have some kind of topic entity to group the entries in the same thread. And another issue to index with concatenation is it would need to re-index once new entry is posted which has performance impact.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文