我有一个庞大的文本文件数据库(sql server)(目前为~500GB)。我对它们进行全文搜索。
我想为此目的使用solr / elastic搜索。
但是,文本文档与组织中的角色相关联,即:经理文档或老板的文档。人们的角色偶尔会发生变化。
我没有为此目的编写SQL查询的问题。
我想不出对Solr /弹性搜索做同样的事情。
你会如何解决这个问题?
答案 0 :(得分:1)
关于此主题“Custom security filtering in Solr”有一篇很好的博文。它显示了如何实现PostFilter接口,您可以在其中执行Java提供的任何操作来检查是否可以访问文档。这适用于您拥有一些保存访问信息的远程系统的情况,例如公司LDAP。
但正如作者所说,
重要的是要注意PostFilter是实现文档过滤的最后手段。不要让解决方案比它需要的更复杂。通常,甚至访问控制过滤也可以使用普通的搜索技术,通过将允许的用户和组索引到文档上并使用lucene(或另一个)查询解析器来实现。只有当规则过于复杂或需要外部信息时,自定义PostFilter才有意义。
这意味着:是否无法将字段添加到包含访问信息的文档中?像
这样的东西<fields>
<!-- your other fields -->
<field name="owner"
type="String" indexed="true" stored="true" multiValued="false" />
<field name="team"
type="String" indexed="true" stored="true" multiValued="false" />
<field name="team-lead"
type="String" indexed="true" stored="true" multiValued="false" />
<field name="roles"
type="String" indexed="true" stored="true" multiValued="true" />
</fields>
然后在搜索时可以添加到查询
q = some + cool + query&amp; fq = owner:username + OR + team:用户的团队名称+ OR +角色:role1