0

我有一个包含文件列表的应用程序。这些文档使用 Lucene 进行索引。我可以搜索文档的关键字。我循环 TopDocs 并获取与我的关系数据库中的 ID 列相关的 ID 字段(每个 Lucene 文档的)。从所有这些 ID 中,我创建了一个列表。在构建 ID 列表之后,我进行了一个数据库查询,该查询正在执行以下 SELECT 语句 (JPA):

SELECT d From Document WHERE id IN (##list of ID's retrieved from Lucene##)

此文档列表被发送到视图 (GUI)。

但是,有些文档是私有的,不应该在列表中。因此,我们在 SELECT 查询中有一些额外的语句来做一些安全检查:

SELECT d From Document WHERE id IN (##list of ID's retrieved from Lucene##)
AND rule1 = foo
AND rule2 = bar

但是现在我在想:我是用 Lucene 的速度来快速搜索文档,但我还是要做 SELECT 查询。所以我在这个方面失去了性能:-( ... Lucene 是否有一些组件可以为你做这个映射?或者有没有关于这个问题的最佳实践?大型项目如何将 Lucene 结果映射到关系数据库?因为视图应该呈现结果?

非常感谢!

约臣

4

3 回答 3

0

Some suggestions:

  • In Lucene, you can use a Filter to narrow down the search result according to your rules.
  • Store the primary key or a unique key (an ID, a serial number, etc.) in Lucene. Then, your relational database can make unique key lookups and make things very fast.
  • Lucene can act as storage of your documents too. If applicable in your case, you just retrieve the individual documents' content from Lucene and don't need to go to your relational database.
于 2012-07-05T21:22:00.533 回答
0

为什么不用lucene来索引数据库中的表呢?这样您就可以在 1 个 lucene 查询中完成所有操作。

于 2012-07-05T11:34:10.517 回答
0

如果这是一个大问题,也许值得看看支持文档级别安全性的ManifoldCF可能满足您的需求。

于 2012-07-05T19:59:20.750 回答