Faceted search

Submitted by rnsrk on Tue, 11/09/2021 - 10:54

Prerequisites

Installation

Facet module

Open a Terminal at your root-dir ...is the directory, where your Drupal website files and folders are stored (core, modules, sites, themes, .htaccess etc.), if you follow the recommended project structure it's the web folder of your project directory, i.e. /var/www/html/wisski.com/web, or C:/xampp/htdocs/wisski.com/web. and type

composer require 'drupal/facets:1.x-dev@dev'

Go to Manage Extend and check Facets and click Install.

Configuration

Add fields for facet to index

Visit Manage Configuration Search API (Search and Metadata section). In the row of your solr-index ... where you configure the datasources, fields and processors of the things, you want to be searchable, has an administrative name like Specimen. , unfold the Operations menu by clicking on the caret and select Fields. Click + Add fields and on the Add fields to index pop up, Add one or more filter-fields ... are the fields whose values will serve as a filter for your WissKI entities, i. e. Encounter Location. . Save changes, go the View tab and click Index now.

Navigate to Manage Configuration Facets (Search and Metadata section) and click + Add facet. Select the view-for-fulltext-search ... is the view configuration for your Solr fulltext search, i. e. with a administrative name like Specimen fulltext. as the Facet source and one of your filter-fields ... are the fields whose values will serve as a filter for your WissKI entities, i. e. Encounter Location. as Field. You may want to change the facet-name ... is the administrative name of the facet and identically with the block name of the facet, i. e. Filter for encounter location. , then Save. On the Edit page for the facet, the default state of the settings is fine, click Save.

Now go to Manage Structure Block layout. Click on Place block next to a Sidebar region. Search for your facet-name ... is the administrative name of the facet and identically with the block name of the facet, i. e. Filter for encounter location. and click Place block again. You may want to restrict the pages, where the block is visible to the view-for-fulltext-search ... is the view configuration for your Solr fulltext search, i. e. with a administrative name like Specimen fulltext. . Save block.

Check results

Visit your view-for-fulltext-search ... is the view configuration for your Solr fulltext search, i. e. with a administrative name like Specimen fulltext. by navigating to Manage Structure Views and click at the page route in the Displays column. You should see the facet block on the sidebar, and if you click on a criteria, the result set should change.

Was this reply helpful?
1
0
2 votes with an average rating of 0.5.

Need help?