[英]Solr index directory of files add file permissions from database
I'm using Solr to index a directory of pdf and word files. 我正在使用Solr来索引pdf和word文件的目录。 I want Solr to search these files but only return results based off a logged in user's permissions. 我希望Solr搜索这些文件,但仅基于登录用户的权限返回结果。 Is it possible to index a directory of files as well as query a database containing the file permissions and add the data to the index as a xml entity and perform a filtered query on those results? 是否可以索引文件目录以及查询包含文件许可权的数据库并将数据作为xml实体添加到索引,然后对这些结果执行过滤查询?
I am using WordPress as the CMS system with a file management plugin called Filebase. 我正在将WordPress作为CMS系统使用一个名为Filebase的文件管理插件。 Filebase syncs with a directory to upload documents to the site. 文件库与目录同步,以将文档上载到站点。 I have Solr configured to index the filebase directory containing the documents. 我已将Solr配置为索引包含文档的文件目录。 Filebase has permissions that I set on each file. 文件库具有我在每个文件上设置的权限。
My thought is if I can store the file's minimum user level position integer in the index I can then perform a filtered query to only display results with a user level of 'x'. 我的想法是,如果可以将文件的最小用户级别位置整数存储在索引中,然后可以执行过滤查询以仅显示用户级别为“ x”的结果。
I hope this makes sense. 我希望这是有道理的。
Yes, if you are on Solr 4+, you can push a Partial Update to Solr index. 是的,如果您使用的是Solr 4+,则可以将部分更新推送到Solr索引。
SCHEMA 施玛
For partial update, all fields in your schema.xml need to be stored . 为了进行部分更新, 需要存储schema.xml中的所有字段 。
This is how your fields section should look like in schema.xml: 这是您的字段部分在schema.xml中的外观:
<fields>
<field name="id" type="string" indexed="true" stored="true" required="true" />
<field name="title" type="text_general" indexed="true" stored="true"/>
<field name="description" type="text_general" indexed="true" stored="true" />
<field name="body" type="text_general" indexed="true" stored="true"/>
<field name="permission" type="integer" indexed="true" stored="true" />
</fields>
INDEXING: 索引:
You can first index all documents(directory of pdf and word) to your index. 您可以首先将所有文档(pdf和word的目录)索引到索引。
Then you can send a partial update to the permission field for a particular id. 然后,您可以将部分更新发送到特定ID的权限字段。
When you send partial update, what actually happens in background is: 发送部分更新时,后台实际发生的情况是:
Suppose you want to set permission=5 for document with id=document_1, your query should look like: 假设您要为id = document_1的文档设置权限= 5,则查询应类似于:
localhost:8080/solr/update?commit=true' -H 'Content-type:application/json' -d '[{"id":"document_1","permission":{"set":5}}]
Here is a good documentation on partial updates: http://solr.pl/en/2012/07/09/solr-4-0-partial-documents-update/ 这是有关部分更新的良好文档: http : //solr.pl/zh-CN/2012/07/09/solr-4-0-partial-documents-update/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.