假设我们有可搜索的 Lucene 文档,例如:
Document 1:
This is first sentence.
Document 2:
This is second sentence.
Document 3:
This is third sentence.
除了上述三个文档之外,我们还有一个 SUPER
文档,其中包含所有三个文档的文本,以支持对 1
、2
和 { 的内容进行邻近搜索{1}} - 所以它看起来像:
3
现在查询:
Document SUPER:
This is first sentence.
This is second sentence.
This is third sentence.
将返回 first
查询:
Document 1
将返回 second
查询:
Document 2
将返回 "first third"~20
。
我们想要实现的是让 Lucene 在这种情况下返回 Document SUPER
和 Document 1
,并带有突出显示的字段 Document 2
和 first
。因此,需要某种从 third
到子文档的突出显示映射。
解决这个问题的最佳方法是什么?
旁注: 我不是要一个完整的解决方案。我只是想知道如何使用现有的 Lucene API 解决这个问题(如果有一个支持这个)......