{"id":60065,"date":"2024-01-20T17:09:50","date_gmt":"2024-01-20T11:39:50","guid":{"rendered":"https:\/\/www.tothenew.com\/blog\/?p=60065"},"modified":"2024-01-31T20:25:18","modified_gmt":"2024-01-31T14:55:18","slug":"exploring-faceted-search-implementing-and-configuring-faceted-search-with-views-in-drupal-9","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/exploring-faceted-search-implementing-and-configuring-faceted-search-with-views-in-drupal-9\/","title":{"rendered":"Exploring Faceted Search: Implementing and Configuring Faceted Search With Views in Drupal 9"},"content":{"rendered":"<h2><strong>Introduction<\/strong><\/h2>\n<p>Drupal 9, a powerful and flexible content management system, offers a robust solution for implementing faceted search through its Views module. In this blog post, we&#8217;ll dive into the process of implementing and configuring faceted search using Views in Drupal 9. Faceted Search allows users to filter and refine search results based on various attributes or facets. These facets can include categories, tags, dates, and any other relevant metadata associated with the content.<\/p>\n<p><strong>Step 1 : For using Facet Search, we will require modules.<\/strong><br \/>\nInstall and enable these two modules:<\/p>\n<p>Facet Module<br \/>\nSearch API Module<\/p>\n<p><strong>Step 2 : Add Content-Type and Content<\/strong><br \/>\nNavigate to Structure &gt;&gt; Content type &gt;&gt; Add content type.<br \/>\nAdd Content for the Content type you want to add content.<\/p>\n<p><strong>Step 3 : Configure Search Server<\/strong><br \/>\nNavigate to Configuration -&gt; Search and Metadata -&gt; Search-API from the admin interface to configure your search server.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-60055 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step1.png\" alt=\"\" width=\"850\" height=\"360\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step1.png 850w, \/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step1-300x127.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step1-768x325.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step1-624x264.png 624w\" sizes=\"(max-width: 850px) 100vw, 850px\" \/><\/p>\n<p><strong>Step 4 : Configure the Search Index<\/strong><br \/>\nNavigate to Configuration -&gt; Search and Metadata -&gt; Search-API -&gt; Index.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-60056 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step2.png\" alt=\"\" width=\"850\" height=\"360\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step2.png 850w, \/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step2-300x127.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step2-768x325.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step2-624x264.png 624w\" sizes=\"(max-width: 850px) 100vw, 850px\" \/><\/p>\n<p>Now, give a name to the search index and select content as a datasource. After that, configure the content data source. Here, you can select all the bundles or any specific bundles you want to index for faceted search.<\/p>\n<p>Select your server (created in Step 3). Check &#8220;Index items immediately&#8221; under index options to index content immediately when you create new content.<\/p>\n<p><strong>Step 5 : Add Fields for Indexing<\/strong><br \/>\nNavigate to Configuration -&gt; Search and Metadata -&gt; Search API -&gt; Edit your index and select the Fields tab.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-60057 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step3.png\" alt=\"\" width=\"850\" height=\"360\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step3.png 850w, \/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step3-300x127.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step3-768x325.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step3-624x264.png 624w\" sizes=\"(max-width: 850px) 100vw, 850px\" \/><br \/>\nClick on the &#8220;Add fields&#8221; button to Add fields according to your requirement.<\/p>\n<p><strong>Step 6 : Index the Content for Facet Search<\/strong><br \/>\nClick on the View tab, and under Start Indexing Now, click on Index now.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-60058 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step4.png\" alt=\"\" width=\"850\" height=\"360\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step4.png 850w, \/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step4-300x127.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step4-768x325.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step4-624x264.png 624w\" sizes=\"(max-width: 850px) 100vw, 850px\" \/><\/p>\n<p><strong>Step 7 : Create A View<\/strong><br \/>\nNavigate to Structure -&gt; Views -&gt; Add View.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-60059 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step5.png\" alt=\"\" width=\"850\" height=\"360\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step5.png 850w, \/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step5-300x127.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step5-768x325.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step5-624x264.png 624w\" sizes=\"(max-width: 850px) 100vw, 850px\" \/><\/p>\n<p>Add view Name. Under View Settings, choose your index name (created in Step 4).<br \/>\nCreate a page and click Save and Edit. Add view fields (add the fields you added for indexing under Step 5).<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-60060 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step6.png\" alt=\"\" width=\"850\" height=\"360\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step6.png 850w, \/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step6-300x127.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step6-768x325.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step6-624x264.png 624w\" sizes=\"(max-width: 850px) 100vw, 850px\" \/><\/p>\n<p><strong>Step 8 : Create\/Configure A Facet<\/strong><br \/>\nThe Facets module extends the Views module to allow the creation of facets for building faceted search interfaces.<\/p>\n<p>Navigate to Configuration -&gt; Search and Metadata -&gt; Facets. Click &#8220;Add facet.&#8221;<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-60061 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step7.png\" alt=\"\" width=\"850\" height=\"360\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step7.png 850w, \/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step7-300x127.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step7-768x325.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step7-624x264.png 624w\" sizes=\"(max-width: 850px) 100vw, 850px\" \/><br \/>\nSelect facet source as your newly created view from Step 7. Select the field added in Step 5. Add a Name. Click Save. On the next screen, you will see multiple settings for your newly created facet.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-60062 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step8.png\" alt=\"\" width=\"850\" height=\"360\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step8.png 850w, \/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step8-300x127.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step8-768x325.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step8-624x264.png 624w\" sizes=\"(max-width: 850px) 100vw, 850px\" \/><\/p>\n<p>From Widget, you can select 4 different widgets (links, drop-down, checkbox, raw result). You can do other settings based on your requirements. Select &#8220;Transform entity ID to label&#8221; to display the Content Type label instead of ID.<\/p>\n<p>Note: You can add multiple facets, allowing users to refine their search based on various fields.<\/p>\n<p><strong>Step 9 : Placing The Facet Block<\/strong><br \/>\nFacets can be displayed as blocks, allowing you to place them in different regions of your site.<br \/>\nNavigate to Structure -&gt; Block Layout.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-60063 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step9.png\" alt=\"\" width=\"850\" height=\"360\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step9.png 850w, \/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step9-300x127.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step9-768x325.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step9-624x264.png 624w\" sizes=\"(max-width: 850px) 100vw, 850px\" \/><\/p>\n<p>Choose a region based on your requirement and click on Place Block. Search for the newly created facet block and click Place block. Under configure, add the view Path name. Click on Save block.<\/p>\n<p>After all these settings, our <strong>Final Result<\/strong> will look like this.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-60064 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step10.png\" alt=\"\" width=\"850\" height=\"360\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step10.png 850w, \/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step10-300x127.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step10-768x325.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/01\/Step10-624x264.png 624w\" sizes=\"(max-width: 850px) 100vw, 850px\" \/><\/p>\n<div class=\"ap-custom-wrapper\"><\/div><!--ap-custom-wrapper-->","protected":false},"excerpt":{"rendered":"<p>Introduction Drupal 9, a powerful and flexible content management system, offers a robust solution for implementing faceted search through its Views module. In this blog post, we&#8217;ll dive into the process of implementing and configuring faceted search using Views in Drupal 9. Faceted Search allows users to filter and refine search results based on various [&hellip;]<\/p>\n","protected":false},"author":1708,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":23},"categories":[3602],"tags":[5609],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/60065"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/1708"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=60065"}],"version-history":[{"count":3,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/60065\/revisions"}],"predecessor-version":[{"id":60161,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/60065\/revisions\/60161"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=60065"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=60065"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=60065"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}