What is Facet Search?

Facet search is a way to filter content dynamically. It comes with multiple filters at the same time for the various attributes of the content. Facets will also display the number of matched results next to them. It works with the Drupal core and search API. Facet 3.0.x works with drupal 9 or 10.

Module Requirement

Facet Module 
Search API module
Search API Solr

Step 1

Create a content type that you would like, or you can use an existing one.

Navigate to Structure >> Content type >> Add content type

Step 2

Configure the Search Server
Navigate to Configuration >> Search and Metadata >> Search API >> Add server.

Server name, Solr host, and Solr core are all important fields you need to add.

Finally, save it.

Step 3

Next, configure the search index.
Navigate to Configuration >> Search and Metadata >> Search API >> Add index.

Configure the content datasource. Select bundles you can choose all also.

Select server and finally, save it.

Step 4

Add Fields for Indexing
Navigate to Configuration >> Search and metadata >>Search API >> Add index and select the Fields tab. Add fields as needed and save your changes.

Click on view to index the content within the same. To begin indexing, click the “index now” button.

Step 5

Create a views in Drupal 9

Navigate to Structure >> Views >> Add View.

Add the view’s name or a description. In the view setting, choose Created Index in Step 3.
Make a page with your suggestions for the page title and path. Set up all settings and click on “Save and Edit.”
Insert Fields into the view. Inside the render setting and select the Link to Content checkbox.

Ref. https://www.drupal.org/docs/8/core/modules/views

Step 6

Configure the facets.
Go to Configuration >> Search and meta data >> Facets
Click on the “add facet” button. Select Facet source – This is your views.
Select fields – This is what you had created for indexing in step 4.
Name it and save it.

Next, you will see more configuration options. Change the settings to meet your needs.

Finally, save it.

Step 7

Next, place the facets in block layout in a page region of your choice.

Go to Structure >> Block Layout.

Place the block and save it.

Result

Hurray! Your facet search page and functionality are now ready. As you can see, some categories, such as A, B, and so on, are facets search. We used the checkbox widget in Step 6.

Conclusion

Our facets search has been successfully implemented. We learned about faceted search, the search API module, content type, views, and facets functionality. Happy Learning!!!