Faceting in Islandora¶
This tutorial contains are step-by-step instructions for adding a facet on a vocabulary reference field. After a search, a block containing the configured facets appears letting the user filter their search.
This is a walk-through. For a more in-depth discussion of creating facets, see Configure Advanced Search
This tutorial currently works best with the "standard" install of the Islandora and Islandora Default modules which can be obtained from the playbook (as opposed to the install profile, which handles facet blocks differently).
Step 1: Add vocabulary bundles¶
Steps 1 and 2 add the field to the Solr index.
- Go to Admin >> Configuration >> Search and Metadata >> Search API (or, /admin/config/search/search-api)
- Edit the Default Solr content index
- Open the Configure the Taxonomy term datasource field-set, choose the vocabulary bundles you want to add to be indexed
- Click Save
Step 2: Add fields¶
- Back at the edit Default Solr content index, choose Fields from the tabs across the top
- Click on the Add fields button
- Scroll down to Content
- Click on the + next to the field you want to add.
- Click on the + next to "Taxonomy term". A bunch of subfields will appear.
- Look for the field that contains "YOUR_FIELD:entity:name" and click on the "Add" button at the end of the bulleted point.
- Click “Done.”
- Find your newly added fields In the list, and ensure the "Type" of the new field is "string" so it can be compatible with Facets.
- If the "Machine name" of the new field is generic, like "name_1", change it to be the same as the part of the "Property path" up to the first : (this will be the same as the field's machine name).
- Click on the Save changes button.
Step 3: Rebuild Solr index¶
Now that you've added the field, you need to rebuild your Solr index.
- Go back to Default Solr content index (admin/config/search/search-api/index/default_solr_index)
- Click on the Index now button.
Step 4: Add and configure facet¶
Step 4 adds and configures the facet itself.
- Go to Admin >> Configuration >> Search and Metadata >> Facets** (admin/config/search/facets)
- Click on the Add facet button
- Select the View Solr search content source
- In the Field list, select the field you added above
- You can adjust the admin Name of the facet
- Click **Save".
- Choose your configuration options (for example, "List item label")
- Click Save.
Step 5: Add facet as a block¶
This step adds the facets in a single block.
- To place a Facets block for the facets you have created, go to Admin >> Structure >> Blocks layout (admin/structure/block).
- Click Place block in the desired block region, for example, Sidebar second.
- Start typing the facets block in the Filter and click Place block
- Choose the facets to include
- Choose other configuration options for the block, for example change the title that displays and restrict by content type, etc.
- Click Save.
At this point, searching for content that has facet values should cause the block to appear. For more in-depth overview of search, see Configure Advanced Search
Facets aren't necessarily searchable
While this will create facets, the values that appear won't work (won't necessarily bring back any content) if you type them in the search box. This is because the fulltext search box uses only fulltext fields, and facets, as mentioned above, requires string fields.
If you want to be able to search for taxonomy term values and bring up the related nodes, you could either include the full rendered item for your content type, or you may wish to repeat step 2 for each entity reference field, and set the new fields to fulltext so that searching for term values brings back node results.