简体   繁体   English

根据用户限制来限制Lucene.Net搜索结果

[英]Limit Lucene.Net Search Results based on user restrictions

I am trying to figure out how to manage restricted data within a Lucene.Net index, say you have a person document with something like: 我试图弄清楚如何在Lucene.Net索引中管理受限数据,比如说您有一个人文档,内容如下:

Name: Peter Pan
Locations: Neverland, London, Paris

Now say that I had 2 users, UserA and UserB, and that whay they individually was allowed to see was: 现在说我有两个用户,UserA和UserB,分别允许他们查看的方式是:

UserA: 
  Name: Peter Pan
  Locations: Neverland, London

UserB: 
  Name: Peter Pan
  Locations: London, Paris

Now I wish to allow both of them to search on Locations, however since UserB can't see that Peter Pan has been to Neveland, Searching on "Neverland" would not yeld Peter as a result to UserB, Visa-Versa with UserA and Paris, but both can see London... 现在,我希望允许他们两个都在“位置”上进行搜索,但是由于UserB看不到Peter Pan曾经去过Neveland,因此在“ Neverland”上进行搜索不会向PeterB,UserA的Visa-Versa和Paris屈服Peter ,但都可以看到伦敦...

The data I have to deal with is vastly more complex than that, bu the way these things are turned on and off are by what we call caveats, so to dive deeper into the above, the reason they see what they see could by example be that they have the rights to view data with the following caveats: 我要处理的数据远比这要复杂得多,因为打开和关闭这些内容的方式取决于我们所说的警告,因此,请更深入地研究上述内容,以了解他们看到示例的原因是他们有权查看以下注意事项的数据:

UserA: AAA, BBB
UserB: BBB, CCC

And because the location data entries for peter are tagged as: 并且因为彼得的位置数据条目被标记为:

Neverland - AAA
London - BBB
Paris - CCC

As an example... 举个例子...

I hope this sorts of outlines the situation good enough to at least start a discussion. 我希望这种概述足以使情况至少能够开始讨论。

1. Replicate Model 1.复制模型

Obviously I could properly separate all data entries up into the bits that make up a "document" instead of storing Peter Pan as one big document, I could fragment it out, but that would leave me with a situation where I could possibly get multiple hits on the same actual objects as I see it... It would also be allot of fields. 显然,我可以将所有数据条目正确地分成组成“文档”的位,而不是将Peter Pan存储为一个大文档,我可以将其碎片化,但是这样会使我陷入多次打击的境地在与我看到的相同的实际对象上……这也将是字段的分配。

2. Multiple Documents 2.多个文件

Alternatively I could store one document pr. 或者,我可以存储一个文档。 restriction with just the data a for what a single caveat may give the rights to, again as far as I can tell this gives multiple hits and it also gives allot of "redundant" data. 仅限于数据a单个警告可能授予的权利,据我所知,这给出了多个匹配,还分配了“冗余”数据。

3. Filtering by DataBase roundtrip 3.按数据库往返过滤

Lastly but not least I could perform the search ignoring caveats, and then rather than displaying the results directly from Lucene, I could let our DataAccess tier do the caveat filtering for me, that would add a round-trip to the database earlier than needed though. 最后但并非最不重要的一点是,我可以忽略搜索而执行搜索,而不是直接显示来自Lucene的结果,我可以让我们的DataAccess层为我执行警告过滤,这样虽然比需要的时间更早地向数据库添加了往返。

Although the round-trip to the database might be the least of my concern here. 尽管往返数据库可能是我最不关心的问题。 There is also the fact. 也有事实。 that Lucene would return hits that might not actually be hits when it comes to the search term, as the value generating that hit might not be visible to that user. Lucene会返回在搜索字词中实际上可能不是真正的匹配的匹配,因为生成该匹配的值可能对该用户不可见。

This also means the "number of results" might be off. 这也意味着“结果数”可能会关闭。

All in all, it wouldn't just be an extra database round-trip, we would have to also "redo" the filtering after that result had been pulled up. 总而言之,这不仅是一次额外的数据库往返,我们还必须在结果被提取后再“重做”过滤。


I would hear if I could reach someone with more Lucene experience than my self to give some input if possible. 我会听我说是否可以联系比我自己拥有更多Lucene经验的人提供一些建议。

Thanks in advance. 提前致谢。

If you can assign permissions by groups (ie "all users who cannot see trips to Neverland"), you could add a field (or fields depending on the complexity of your permissions) to each document that informs the UI to ignore all trips to Neverland. 如果可以按组分配权限(即“所有看不到Neverland旅程的用户”),则可以向每个文档添加一个字段(或多个字段,具体取决于权限的复杂性),以通知UI忽略所有Neverland旅程。

If you cannot group permissions, it would be possible (if unwieldy in the presence of large numbers of users) to add permissions for each user to each document, then have the UI process those permissions appropriately. 如果您不能对权限进行分组,则可以(如果在大量用户的情况下笨拙)将每个用户的权限添加到每个文档,然后让UI适当地处理这些权限。 This would let you have separate permissions for each document for each user (similar to filesystem permissions). 这将使您对每个用户具有针对每个文档的单独权限(类似于文件系统权限)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM