-
Notifications
You must be signed in to change notification settings - Fork 41
Lesson indexing hydra rights metadata into solr
This Tutorial is known to work with hydra-head version 6.4.0.
Please update this wiki to reflect any other versions that have been tested.
Given a book whose permissions look like this:
book.permissions_attributes = [{:type=>"group", :access=>"discover", :name=>"group2"},
{:type=>"group", :access=>"read", :name=>"group3"},
{:type=>"group", :access=>"read", :name=>"group9"},
{:type=>"group", :access=>"read", :name=>"group8"},
{:type=>"user", :access=>"read", :name=>"user3"},
{:type=>"user", :access=>"edit", :name=>"bob1"},
{:type=>"user", :access=>"edit", :name=>"sally2"}]
By default, the permissions will be written into the a solr document like so
pp book.rightsMetadata.to_solr
{"discover_access_group_ssim"=>["group2"],
"read_access_group_ssim"=>["group3", "group9", "group8"],
"edit_access_person_ssim"=>["bob1", "sally2"],
"read_access_person_ssim"=>["user3"]}
Note: The suffix _ssim
on the solr fields is using the Hydra solr schema designed by Naomi Dushay. It means that the values should be treated at strings, should be both stored and indexed, and are allowed to be multivalued.
As you can see, the arrays of group ids and user ids returned by methods like discover_groups
, read_groups
, edit_users
, etc. are all being indexed into solr. This makes it possible for us to filter search results based on a user's id and group memberships. That filtering of search results based on user-specific access permissions is often called gated discovery.
Go on to Lesson - Looking up which groups a user belongs to or return to the Access Controls with Hydra tutorial.