简体   繁体   English

Solr文件索引目录从数据库添加文件权限

[英]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: 发送部分更新时,后台实际发生的情况是:

  • Solr will go and fetch values for all other fields for that document, such as title, description, body Solr将为该文档的所有其他字段获取值,例如标题,说明,正文
  • Delete old document 删除旧文件
  • Push new updated document to Solr index, with all existing fields as well as new permission field 将所有现有字段以及新的权限字段推送到新的更新文档到Solr索引

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.

相关问题 如何使用我的站点目录中的现有文件创建wordpress数据库文件? - How to create a wordpress database file with existing files in my site directory? 我无法在自定义目录中添加自己的index.php文件,Wordpress会使其“覆盖” - I can't add my own index.php files in a custom directory, Wordpress keeps 'overriding' it 以下目录/文件的写入权限问题 Elementor 上传目录 - Writing permissions issues with the following directories/files Elementor uploads directory 从服务器 wordpress 插件检查和 999 个文件的限制添加文件 - Add file from server wordpress plugin checking and limit of 999 files 谁能告诉我如何对Web主机上目录中的每个文件和目录授予相同的权限集? - Can anyone tell me how to grant a same set of permissions to every file and directory inside a directory on web host? 在Wordpress AJAX中,调用一个PHP文件,该文件正在从数据库中获取数据并返回到索引文件 - In Wordpress AJAX call for a PHP File that is getting data from Database and returning to Index file WAMP服务器不处理索引文件(而是显示目录列表) - WAMP server not processing index files (shows directory listing instead) .htaccess WordPress忽略目录并从该目录中删除index.php - .htaccess WordPress ignore directory and remove index.php from that directory WordPress-插件-将WP插件目录中的图像文件放入JS文件 - WordPress - Plugin - enqueue image files from WP plugin directory in a JS-file 如何包含相对于文件目录的文件 - How to include files relative to a file's directory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM