Strawberry Key Name Providers, Solr Field, and Facet Configuration
For an overview of how Strawberry Key Name Providers fit within the context of the rest of Archipelago, please see the Drupal and JSON section in our Metadata in Archipelago overview documentation.
In order to expose the Strawberry Field JSON keys (and values) for Archipelago Digital Objects (ADOs) to Search/Solr, Views, and Facets, we need to make use of a plugin system called Strawberry Key Name Providers. The following guide covers - Configuring first the Strawberry Key Name Providers - Then configuring the corresponding Solr Fields necessary for Search and Views exposure - Finally, the configuration of Facets and placement of Facet blocks on your theme as needed.
Creating a Strawberry Key Name Provider
-
First, we'll start with an example of a Strawberry Field JSON key that we would like to expose:
date_created_edtf
... "subject_wikidata": [ { "uri": "http:\/\/www.wikidata.org\/entity\/Q55488", "label": "railway station" } ], "date_created_edtf": { "date_to": "", "date_free": "2016~\/2017~", "date_from": "", "date_type": "date_free" }, "date_created_free": null, ...
-
Next, we are going to create a new Strawberry Key Name Provider by going to
Administration > Structure > Strawberry Key Name Providers
, pressing the+ Add Strawberry Key Name Provider
button, filling in the fields as follows, and saving:Label
:Date Created EDTF
Strawberry Key Name Provider Plugin
:JmesPath Strawberry Field Key Name Provider
One or more comma separated valid JMESPaths
:date_created_edtf.date_free
- Confirm that the value for
Exposed Strawberry Field Property
(under theOne or more comma separated valid JMESPaths
field) is set todate_created_edtf_date_free
. This is theStrawberry Field Property
that will hold the data coming from the JMESPath Query when evaluated against and ADO's JSON and will be visible as a Strawberry Field Property to Drupal and the Search API. When doing this in a production environment, you might want to change the automatically generated value and assign a simpler one to remember. You can always do this by pressingEdit
. But for the purpose of this documentation please keepdate_created_edtf_date_free
. Is Date?
:☑
Strawberry Key Name Provider Plugins
You'll notice that there are four plugins, each with different options, available for different use cases. Below you'll find each plugin with examples from the providers that come with a default deployment.
Entity Reference JmesPath Strawberry Field Key Name Provider
ismemberof
One or more comma separated valid JMESPaths: ismemberof
Entity type: node
Flavor/Embedded JSON Service Strawberry Field Key Name Provider
hoCR Service
Source JSON Key used to read the Service/Flavour: ap:hocr
JmesPath Strawberry Field Key Name Provider
Subject Labels
One or more comma separated valid JMESPaths: subject_loc[*].label, subject_wikidata[*].label, subject_lcnaf_geographic_names[*].label,subject_temporal[*].label, subject_lcgft_terms[*].label, term_aat_getty[*].label, pubmed_mesh[*].label
JSONLD Strawberry Field Key Name Provider
Best Practice
As in the example below, if there are a group of flat and unique keys that you want to expose, we recommend creating one provider with this plugin and using a list of keys instead of creating multiple providers. This Provider will also auto assign Lists of Properties from an external JSON-LD ontology/vocabulary (e.g Schema.org). It uses direct access approach, e.g. type
will get all values for any JSON Key named type
at any hierarchy level (across the whole JSON document) and it will also use the same exact name (type
) for the Exposed Strawberry Field Property
.
schema.org
Additional keys separated by commas: ismemberof,type,hocr,city,category,country,state,display_name,author,license
Creating a Solr Field
- Go to
Administration > Configuration > Search and metadata > Search API > Drupal Content to Solr 8 > Fields
. - Press the
Add fields
button. - Search for the field created above (expand the
🍓 Strawberry (Descriptive Metadata source) (field_descriptive_metadata)
, e.g. for the key mapped above, look forfield_descriptive_metadata:date_created_edtf_date_free
. - Scroll down after adding to make sure the
Type
for the field is correct (date
for the example in this guide). - Reindex Solr.
- Go to
Administration > Configuration > Search and metadata > Search API
and click on the link to the index for your Drupal data. - Press the
Queue all items for reindexing
button. - Let cron reindex or press the
Index now
button.
- Go to
Creating a Facet
- Go to
Administration > Configuration > Search and metadata > Facets
. - Press the
+ Add facet
button. - Select your facet settings. For the example in this guide, we'll select the following:
Facet source
:View Solr search content, display Page
Field
:🍓 Strawberry (Descriptive Metadata source) >> date_created_edtf_date_free (field_descriptive_metadata:date_created_edtf_date_free)
Name
:🍓 Strawberry (Descriptive Metadata source) >> date_created_edtf_date_free
- Save.
- Continue with the facet configuration by pressing
Edit
for the facet we just created and adjusting the many options available as needed. For the example in this guide, we'll adjust the below from the default settings:Facet settings
☑
Date item processor
Date display
🔘
Actual date with granularity
Granularity
🔘
Year
URL alias
:sbf_date_created_edtf
- Save.
Creating a Block for the Facet
- Go to
Administration > Structure > Block layout
. - Select the appropriate theme. For the example in this guide, we'll select
Archipelago Base Theme
. - Press the
Place block
button next to the appropriate region. For the example in this guide, we'll be placing the block in theSidebar second
region. - Select your facet from the list. For the example in this guide, we'll select
🍓 Strawberry (Descriptive Metadata source) >> date_created_edtf_date_free
- Press the
Place block
button next to the facet. Once the block is added, you can drag and drop it to change its position among the existing blocks and saving.
Thank you for reading! Please contact us on our Archipelago Commons Google Group with any questions or feedback.
Return to the Archipelago Documentation main page.
Created: December 6, 2022