Faceted Search module provides a search API and a search interface for allowing users to browse content in such a way that they can rapidly get acquainted with the scope and nature of the content, and never feel lost in the data.
This blog will help you in setting up Facet search functionality on your data in Drupal 7. This module will help in easy searching of contents of the site.
In order to make such functionality you need to install couple of modules in your site. We will first make a Indexing engine which will index all your data and then we make blocks of specific data which will allow you to filter all related data to itself.
Modules required for implementing Facet Search:
Install and enable above modules.
Create all the contents you would like to include in facet search
Step 1: Create a content type of your requirement:
Now create some contents with the above content type
Step 2: Configure the Search server:-
Navigate to configuration admin page (configuration/admin) in your Drupal 7 site and click on search API in Search and metadata section. Now we will create a search engine for our data. You should see like below page:
Now click on Add server link .Give name to your server I gave (data server), Choose database service for your service class and click create server. Your server should be like below.
Step 3: Configuring the search Index:
Now configuring the search index is to improve performance for search data retrieval.
From same configuration click on and index in search API option from Search and metadata section.
Values for above form:
Click on create Index.
Now we will select which field to be indexed from our data so we will select fields we want. In our case we will select
And click save configuration.
What we did so far!!
We created our database server, Index server and added fields which need to be index. As you added fields for indexing Facet API actually make Facet blocks of those fields. We will enable these later.
Now run Cron in your site which populates the Index.
Step 4: Create a view of your data which need to be Indexed and Displayed to your site user :
Install Views and enable it. Go to Structure > Views. Clicks add new view. Select below values for each field:
Your view information look like below:
Click on continue & edit button. Now in the Fields section click on add fields and Filter Index node. Add Index fields you want to show to your user. Your selection will look like below.
Complete all configuration of specific field and click Apply Display. You are done with creating view. You are now able to see this view on your front page (/node).
Next step is enabling all blocks of your facet search. Earlier we added fields which need to be Indexed. Actually when you add fields for indexing Facet API it create Blocks of those fields respectively. You have to just enable them from Search settings.
Step 5: Enable Facet block from Search settings:
Go to configuration and click on Search API from search and metadata. Now just click on edit in Index. You are able to see various configuration options like below.
Click on Facets and enable facets you want. When you enable and save configuration. It will create Blocks of respective fields
Step 6: Enable your Facet block from Blocks:
Now go to structures and blocks. Here you are able to see your facet block in Disable section just enable them in any regions of your theme.
Congratulation your site is ready. Visit your home page and it should look like below. As you select options from blocks your main view show you data as per your selection.
Facet API has many configuration options. You should take a look to them like showing selection in Blocks in Checkbox etc. However, facet API not able to give you Multiple Facet searches functionality.