Step by Step : How to implement Facet Search on data in Drupal 7

In this blog I will help you in setting up Facet search functionality on your  data in Drupal 7. However , If you are thinking about creating website where you can show your Big Data and with the help of facet search your website user can actually find specific data related to them. This blog will probably help you.

The 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. More than a search interface, this is an information navigation and discovery tool.

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 to install for implementing Facet Search:

  1. Facet API
  2. Search API
  3. Database search
  4. Search Facets
  5. Search Views
  6. Entity API

We are done with installing and enabling above modules.

Steps to follow:

  1. Create content type and add fields in respective content type.
  2. Configure the search server
  3. configure the search index
  4. Add fields on in Facet API
  5. Create a complete view  of your data

Step 1. Create content type and add fields in that:

Let’s take an example we created content type

  • Title : Company
  • Fields : Address
  • Fields : County

Now just create content of above content type and add data into it.

Right now we have content with data into it and we have modules. Now we need to configure above modules as per our functionality on data.

Step 2. Configure the Search server:-

Go to configuration admin page (configuration/admin) in your Drupal 7 site and click on search API in Search and metadata section . you should be now on Search configuration setting. We will create a search engine for our data. You should see page like below :

Search configuration

Now click on Add server link .Give name to your server I gave (MYSQL) , Choose database service for your service class and click create server. Your server should be  like below.

Selection_002

Step 3. Configure the search Index:

Now we will make our search index which will index all data from using search server and database server. It will do indexing as user search for data on site and give fast result. Go back to search API settings and click on Add Index link. You should be on below page now.

Selection_004

Values for above form:

  • Index name : Business Information
  • Item type: Node
  • Server: MYSQL which you create earlier
  • Index items immediately : Checked

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

  • content type
  • Address
  • Title
  • County

and click save configuration .

What just happened ?

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 . don’t focus on them right now we will enable them later.

Now run Cron in your site which populate 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. click add new view. Select below values for each field:

  • Show content : Business Information “This will be name of your Search server”
  • Create a page: checked
  • Path: node
  • Display format: Table

Your view information look like below:

Selection_005

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 looks like below.

Selection_007

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 to 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.

Selection_008

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 .

Note:-

Facet API have 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 search functionality . So , I am now working on developing custom module of widget and behavior which will give functionality of Multiple facet selection search . Facet API have OR and AND but only AND works not OR among fields.

Please free feel to ask your queries related to Facet search and If you need some more blog’s on Facet search for specific functionality or configuration or custom modification in Facet API then do comment probably I will help you by writing blog on respective.

Thanks to Chetan , Anirudha , Sonali for reading Draft of this .

Advertisements

20 thoughts on “Step by Step : How to implement Facet Search on data in Drupal 7

  1. Hi,
    I use several facet fliters but I want to organize them in breadcrumb and current search block.
    I would like :
    facet1 / facet2/ facet3 for breadcrumb and in current search block :
    (-) Remove facet1 filter facet1
    (-) Remove facet2 filter facet2
    (-) Remove facet3 filter facet3

    today I’ve got facet3 / facet2/ facet1 for example in breadcrumb…
    How can I change this order ?
    Thanks

    • it a problem of url
      here is the url I have (search is the name of the page) :
      search/code_postal/30170/commune/74045/departement/gard
      if I change with this it works :
      search/departement/gard/code_postal/30170/commune/74045
      how can I change this order ?

  2. Is it possible to display all records if search box search with empty?

    Your help would be greatly appreciated!

  3. Hi, Nice article. You have mentioned Business Information as “This will be name of your Search server”, but it is actually the Index Name. Which one should i give while i create a view.?

  4. I found the explanation well, but i have confusion with which exact modules are you referring to in the first “Modules to install” section, i am aware of search_api, facets_api and entity api, but Database Search and others are not crystal clear. Googling with the name is giving weird results (modules for Drupal 6.x ) Will appreciate if you could add links to those modules.

  5. Great posts from you, man. I’ve figured out your point and you’re simply extremely excellent.
    I enjoy what you have here, truly like what you’re saying as well as the way by which you say
    it. You make it compelling. I cant wait to read a lot more from you.

    This is genuinely an excellent website.

  6. This article is very appealing to individuals like me. It’s not only thought-provoking, it
    attracts you in right from the start. This is well-written content.
    The views listed here are also encouraging to me. Thanks.

  7. Hey there I am so pleased I find your site, I actually found you
    by mistake, while I was looking on yahoo and google for something else, Nonetheless I am here now and could just
    like to say many thanks for a tremendous post and engaging site.

    Please do continue the truly great work.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s